home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / UT_SYSTM / CLOCK_RS.ZIP / CLOCK.DOC < prev    next >
Encoding:
Text File  |  1994-11-20  |  167.2 KB  |  4,178 lines

  1.  
  2.  
  3.  
  4.  
  5.           CLOCK Version 3.70                              November 20, 1994
  6.  
  7.  
  8.  
  9.  
  10.                                  Version 3.70
  11.  
  12.  
  13.  
  14.                          CLOCK is a shareware program.
  15.                  See Appendix A for registration information.
  16.                        $10 (or $25 for full source code)
  17.                                 Ronald Q. Smith
  18.                                11 Black Oak Road
  19.                             St. Paul, MN 55127-6204
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                        Copyright 1991-1994 Ronald Q. Smith
  26.  
  27.  
  28.  
  29.  
  30.           CLOCK Version 3.70                              November 20, 1994
  31.  
  32.  
  33.                                    CONTENTS
  34.  
  35.  
  36.      
  37. 1.  INTRODUCTION  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  38.                                                                              4
  39.           
  40.      1.1  Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  41.                                                                              4
  42.           
  43.      1.2  Overview  . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  44.                                                                              5
  45.  
  46.      
  47. 2.  CLOCK.SYS - Replacement Device Driver . . . . . . . . . . . . . . . . . 
  48.                                                                              7
  49.           
  50.      2.1  Unique Clock Hardware Support . . . . . . . . . . . . . . . . . . 
  51.                                                                              7
  52.           
  53.      2.2  Installing CLOCK.SYS  . . . . . . . . . . . . . . . . . . . . . . 
  54.                                                                              8
  55.           
  56.      2.3  Clock Type  . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  57.                                                                             11
  58.           
  59.      2.4  Examples  . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  60.                                                                             13
  61.           
  62.      2.5  Future Enhancements . . . . . . . . . . . . . . . . . . . . . . . 
  63.                                                                             14
  64.  
  65.      
  66. 3.  CLK.EXE - Clock Control Program . . . . . . . . . . . . . . . . . . . . 
  67.                                                                             15
  68.           
  69.      3.1  CLK Command . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  70.                                                                             15
  71.           
  72.      3.2  Using CLK with Windows  . . . . . . . . . . . . . . . . . . . . . 
  73.                                                                             24
  74.           
  75.      3.3  Calculating the Adjustment Factor . . . . . . . . . . . . . . . . 
  76.                                                                             24
  77.           
  78.      3.4  Format of TZ= Function  . . . . . . . . . . . . . . . . . . . . . 
  79.                                                                             25
  80.           
  81.      3.5  Using CLK . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  82.                                                                             28
  83.           
  84.      3.6  Examples  . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  85.                                                                             30
  86.           
  87.      3.7  Errors  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  88.                                                                             31
  89.           
  90.      3.8  Future Enhancements . . . . . . . . . . . . . . . . . . . . . . . 
  91.                                                                             31
  92.  
  93.      
  94. 4.  CLKDEMO.EXE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  95.                                                                             32
  96.           
  97.      4.1  CLKDEMO Command Line  . . . . . . . . . . . . . . . . . . . . . . 
  98.                                                                             32
  99.  
  100.      
  101. 5.  IOCTL - API TO CLOCK.SYS  . . . . . . . . . . . . . . . . . . . . . . . 
  102.                                                                             33
  103.           
  104.      5.1  Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . 
  105.                                                                             33
  106.           
  107.      5.2  clksta  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  108.                                                                             36
  109.           
  110.      5.3  setpw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  111.                                                                             38
  112.           
  113.      5.4  connec  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  114.                                                                             39
  115.           
  116.      5.5  newpw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  117.                                                                             40
  118.           
  119.      5.6  rstrct  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  120.                                                                             42
  121.           
  122.      5.7  stmode  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  123.                                                                             44
  124.           
  125.      5.8  stzone  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  126.                                                                             45
  127.           
  128.      5.9  tdisp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
  129.                                                                             47
  130.  
  131.      
  132. 6.  CLOCK.SYS - ASSEMBLY LANGUAGE API . . . . . . . . . . . . . . . . . . . 
  133.                                                                             50
  134.           
  135.      6.1  Opening the CLOCK$ Device . . . . . . . . . . . . . . . . . . . . 
  136.                                                                             50
  137.           
  138.      6.2  Sending New Values to CLOCK.SYS . . . . . . . . . . . . . . . . . 
  139.                                                                             50
  140.           
  141.      6.3  Getting Current Status of CLOCK.SYS . . . . . . . . . . . . . . . 
  142.                                                                             51
  143.  
  144.      
  145. APPENDIX A:  DEFINITION OF SHAREWARE  . . . . . . . . . . . . . . . . . . . 
  146.                                                                             52
  147.  
  148.      
  149. APPENDIX B:  CLOCK TYPES  . . . . . . . . . . . . . . . . . . . . . . . . . 
  150.                                                                             54
  151.           
  152.      B.1  Type 0 - PC/AT  . . . . . . . . . . . . . . . . . . . . . . . . . 
  153.                                                                             54
  154.           
  155.      B.2  Type 1 - Zenith Z-18x portables, Supersport 20  . . . . . . . . . 
  156.                                                                             54
  157.           
  158.      B.3  Type 2 - Various Zenith Data System PCs.  . . . . . . . . . . . . 
  159.                                                                             55
  160.           
  161.      B.4  Type 3 - Memory-Mapped Clocks . . . . . . . . . . . . . . . . . . 
  162.                                                                             55
  163.           
  164.      B.5  Type 4 - Direct Register I/O Bus Clock  . . . . . . . . . . . . . 
  165.                                                                             56
  166.           
  167.      B.6  Type 5 - Mitsubishi 8088 PCs  . . . . . . . . . . . . . . . . . . 
  168.                                                                             58
  169.           
  170.      B.7  Type 6 - Indirect Register I/O Bus Clock  . . . . . . . . . . . . 
  171.                                                                             59
  172.           
  173.      B.8  Type 7 - Complex I/O Bus Clock  . . . . . . . . . . . . . . . . . 
  174.                                                                             59
  175.           
  176.      B.9  Type 8 - Generic I/O Bus Clock  . . . . . . . . . . . . . . . . . 
  177.                                                                             60
  178.  
  179.                                        2
  180.  
  181.  
  182.  
  183.  
  184.           CLOCK Version 3.70                              November 20, 1994
  185.  
  186.  
  187.           
  188.      B.10 Type 9 - Quadram I/O Bus Clock  . . . . . . . . . . . . . . . . . 
  189.                                                                             60
  190.           
  191.      B.11 Type A - AT&T 6300, 6300 PLUS, 6300 WGS . . . . . . . . . . . . . 
  192.                                                                             61
  193.           
  194.      B.12 Type B - Hyundai 8088 Clock . . . . . . . . . . . . . . . . . . . 
  195.                                                                             62
  196.           
  197.      B.13 Type C - Multi I/O Card Clock . . . . . . . . . . . . . . . . . . 
  198.                                                                             62
  199.  
  200.      
  201. APPENDIX C:  REVISION HISTORY . . . . . . . . . . . . . . . . . . . . . . . 
  202.                                                                             64
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.                                        3
  254.  
  255.  
  256.  
  257.  
  258.           CLOCK Version 3.70                              November 20, 1994
  259.  
  260.  
  261. 1.  INTRODUCTION
  262.  
  263.  
  264. 1.1  Definitions
  265.  
  266. Your PC contains two clocks.  One of these is referred to in this document and
  267. in messages from CLK as the "calendar clock."  The other is referred to as the
  268. "DOS clock."
  269.  
  270. CALENDAR CLOCK
  271.  
  272.      The  calendar clock is the clock that retains the date and time when your
  273.      system  is  turned  off.  It is the clock that requires a battery and for
  274.      that reason is also called the battery-protected clock.  Various hardware
  275.      vendors  also refer to it as the real-time clock, the CMOS clock, and the
  276.      day  clock.    In most systems it is a bit of logic on the motherboard or
  277.      other  add-in  board  and  consists  of a clock chip, a battery, and some
  278.      control  logic.    Some  older clocks are on little mini-boards that plug
  279.      into a cable (e.g., floppy cable) or socket under another chip.
  280.  
  281.      The calendar clock typically has a set of internal counters that maintain
  282.      the  seconds, minutes, hours, day of week, day of month, month, and year.
  283.      Some don't allow you to set the seconds and can only be set on the minute
  284.      even  though  they may allow you to read the seconds.  Many of them don't
  285.      maintain  the  year.  They expect the software to simply keep the year up
  286.      to  date  by  writing  it  to  the chip every time you boot.  Some of the
  287.      calendar  clocks don't handle leap years.  CLOCK.SYS will handle the leap
  288.      years for you on those clocks.
  289.  
  290.      The  calendar  clock  is normally read once when the system is booted and
  291.      the  time  is  then written to the DOS clock.  The calendar clock is then
  292.      normally  never  read  again,  but  it is written if you change the time.
  293.      Since  the calendar clock is usually substantially more accurate than the
  294.      DOS  clock, one of the functions that CLOCK.SYS can perform for you is to
  295.      periodically read the calendar clock and reset the DOS clock.
  296.  
  297. DOS CLOCK
  298.      
  299.      The  DOS clock is really not a clock although it is used like one.  It is
  300.      really  just  a  counter  that increments at a known rate (18.2 times per
  301.      second).    The  DOS  clock  is  also called the BIOS clock, the interval
  302.      timer, and the incrementing counter.
  303.  
  304.      When  you  boot  the  system,  your clock driver software (CLOCK.SYS, the
  305.      driver  built  into  DOS,  or  another  add-in software driver) reads the
  306.      calendar clock and converts the date and time to the number of days since
  307.      January  1, 1980, and the number of seconds since midnight on the current
  308.      day.    The  number  of  days is just saved inside the clock driver.  The
  309.      number  of  seconds  is  converted  to  a number of counter ticks using a
  310.      little  more  exact number than 18.2.  The number of ticks is then stored
  311.      in the counter by calling the BIOS.
  312.  
  313.      When you ask DOS to read the clock, it calls the clock driver which reads
  314.      the  counter  by  calling  the BIOS, converts the number of ticks back to
  315.      seconds,  and returns the number of days that it has saved and the number
  316.  
  317.                                        4
  318.  
  319.  
  320.  
  321.  
  322.           CLOCK Version 3.70                              November 20, 1994
  323.  
  324.  
  325.      of  seconds  to  DOS.    The  BIOS checks to see if the counter goes past
  326.      midnight.    If it does, it resets the counter to zero and tells the next
  327.      caller  that  the  day  has  advanced.    In  that  case the clock driver
  328.      increments the day that is has saved before returning it to DOS.
  329.  
  330.      Unfortunately,  the  BIOS only tells the first caller after midnight that
  331.      the  day  has  advanced.    That  is  the  common  reason for the day not
  332.      advancing on your PC when you leave an application running over midnight.
  333.      Many  applications  use  the BIOS counter internally just to get interval
  334.      timing  information.    When  they  do,  DOS doesn't see that the day has
  335.      advanced.    This is another problem that CLOCK.SYS solves.  It checks to
  336.      see  if  the time ever appears to run backwards and increments the day if
  337.      it does.
  338.  
  339. 1.2  Overview
  340.  
  341. CLOCK  consists  of  two  programs  that  give  you  complete control over the
  342. operation  of  your  calendar  (battery-protected)  clock  and  your  DOS/BIOS
  343. internal  timer.    The  normal  DOS mode of operation is to read the calendar
  344. clock  when  you  boot  the system and set the internal timer.  Thereafter all
  345. read operations refer only to the internal timer while time setting operations
  346. write to both clocks.  In levels of DOS prior to 3.3, even time setting opera-
  347. tions  only  wrote  to the internal timer.  In order to set the calendar clock
  348. you had to run the SETUP program.
  349.  
  350. Some  of  the  drawbacks  to  the  standard DOS clock operation that the CLOCK
  351. programs address are:
  352.  
  353.          There  is  no  provision  to switch time zones without resetting the
  354.           system time.
  355.  
  356.          DOS  does not handle automatic changes between daylight savings time
  357.           and standard time.
  358.  
  359.          The DOS/BIOS internal timer often drifts quite rapidly away from the
  360.           time maintained by the more accurate calendar clock.
  361.  
  362.          Even  the  calendar clock drifts slowly away from the accurate time.
  363.           DOS provides no way to automatically adjust for that drift.
  364.  
  365.          If  your  battery  is  failing  or  some  other hardware or software
  366.           problem  messes  up the time in your calendar clock, there is no way
  367.           to  detect  that except by manually displaying the time and checking
  368.           it.
  369.  
  370.          If  you  have  to  run  a program that occasionally changes the time
  371.           incorrectly,  there  is  no  way  to  protect  your clock from those
  372.           changes.    You can also have this problem if you are a parent whose
  373.           children  set  the  clock when you don't want them to, an instructor
  374.           whose students reset the time, or an expert young user whose parents
  375.           mess up your clock.
  376.  
  377.          If  you  need  to  experiment with special times and dates but don't
  378.           want to have to reset your clock afterwards, DOS has no mechanism to
  379.           h e l p.    In  order  to  test  end-of-month  processing  for  your
  380.  
  381.                                        5
  382.  
  383.  
  384.  
  385.  
  386.           CLOCK Version 3.70                              November 20, 1994
  387.  
  388.  
  389.           application,  you have to set the date and time, run your tests, and
  390.           then set the time and date back.
  391.  
  392.          The  standard  DOS and BIOS software on some PCs can miss the change
  393.           to a new day when the PC is left on over midnight.
  394.  
  395.          Your  clock  might not handle automatic changes to a new year or may
  396.           not understand leap years.
  397.  
  398.          You may have an older PC from before the PC/AT clock standardization
  399.           and  your vendor no longer releases new versions of DOS for that PC.
  400.           You  are  stuck  on  DOS  3.2 or earlier or you have to give up your
  401.           calendar clock.
  402.  
  403. If any of those circumstances cause problems for you, CLOCK can help.  The two
  404. primary  programs  are  CLOCK.SYS  and  CLK.EXE.    In  addition, if you are a
  405. software  developer,  CLKDEMO  is  provided  in source code to show you how to
  406. program the extended clock operations into your own applications.
  407.  
  408.  
  409.      CLOCK.SYS is a clock device driver (CLOCK$ device).  It replaces the
  410.      DOS  internal  clock  driver.  CLOCK.SYS provides for automatic time
  411.      zone conversion.  It also allows you to periodically or continuously
  412.      get  the  time  from the calendar clock.  This can totally eliminate
  413.      problems  with  missing  day  changes  and  realtime clocks that are
  414.      inaccurate.    CLOCK.SYS provides support for many types of calendar
  415.      clocks including many of the original add-in clocks of the 8088 era.
  416.      If  your  clock is not currently supported, I want to hear from you.
  417.      I will be happy to add it to the software.
  418.  
  419.      CLK.EXE  is  a  program  that  allows you to separately control your
  420.      DOS/BIOS  internal clock and battery-protected calendar clock.  Most
  421.      importantly,  CLK.EXE  will handle time zones and will automatically
  422.      switch  between standard and daylight savings time for you.  It also
  423.      supports  automatic  adjustment for calendar clock drift, checks for
  424.      incorrect or unlikely times, and can restrict time changes.
  425.  
  426.      CLKDEMO.EXE  is  a  small part of CLK.EXE that is provided in source
  427.      code  (C language) form so that you can see how to add clock control
  428.      to your own applications.
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.                                        6
  446.  
  447.  
  448.  
  449.  
  450.           CLOCK Version 3.70                              November 20, 1994
  451.  
  452.  
  453. 2.  CLOCK.SYS - Replacement Device Driver
  454.  
  455. CLOCK.SYS  is  a device driver that replaces the built-in CLOCK$ device driver
  456. in  DOS  levels  2.1 and above.  CLOCK.SYS adds many functions not provided in
  457. the  standard  DOS  CLOCK$  device  driver.   You won't see mention of the DOS
  458. CLOCK$  device  driver  in  your DOS user's guides.  You will see a very small
  459. mention  of  it  in  the  system's programmers reference manuals if you are an
  460. assembly language developer.  It is there and DOS was specifically designed to
  461. let  you  replace  it with one of your own even if the manual doesn't tell you
  462. that.
  463.  
  464. 2.1  Unique Clock Hardware Support
  465.  
  466. CLOCK.SYS  was originally written especially for those people whose clocks are
  467. not  supported  by new levels of DOS.  This usually occurs because your vendor
  468. stopped  providing  new levels of DOS adapted for your computer model.  Before
  469. the  days  of  the  PC/AT  and standard clock interfaces, DOS was usually sold
  470. directly  to hardware vendors who customized it for their system and delivered
  471. it  with  the  system.  In addition, many of the early clocks were provided by
  472. third-party, after-market vendors who had no idea what system it would be used
  473. in.    Since  those  systems and clocks have been out of production for a long
  474. time,  most of the vendors have stopped providing upgrades.  Yet most of those
  475. PCs  will  happily run DOS 3.3 or above and especially DOS 5.0 except that you
  476. have to give up your calendar clock.
  477.  
  478. CLOCK.SYS  supports  a  wide  variety  of  different  clock  hardware and BIOS
  479. interfaces.    As far as possible, CLOCK.SYS will automatically determine what
  480. clock interface to use.  If the automatic determination does not work for your
  481. system,  you  may  tell  CLOCK.SYS  specifically  what  interface type to use.
  482. CLOCK.SYS  is  also  required  by  anyone  who wants to use CLK as it provides
  483. functions  not  provided by the normal DOS CLOCK$ device driver.  CLOCK.SYS is
  484. fully  compatible  with the DOS device driver on all modern PCs and many older
  485. ones.
  486.  
  487. If  your  PC clock is not currently supported but you would like to remove the
  488. restrictions on what versions of DOS you can use, please contact me by mail or
  489. on  CompuServe.    I will be happy to add support for your clock.  I will need
  490. some  technical  information and help from you in getting it to work so I will
  491. give  you  a  $0  usage license for your help.  Please see section 2.3 for the
  492. current  list  of  supported  clocks and Appendix B for a description of those
  493. clocks.
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.                                        7
  510.  
  511.  
  512.  
  513.  
  514.           CLOCK Version 3.70                              November 20, 1994
  515.  
  516.  
  517.  
  518. 2.2  Installing CLOCK.SYS
  519.  
  520. To  install  the  device  driver include the following line in your CONFIG.SYS
  521. file.
  522.  
  523. Syntax    device=[d:][path\]clock.sys [type][,io_addr] [/N]
  524.  
  525.                                       or
  526.  
  527.           device=[d:][path\]clock.sys 3[,segment[,write0,
  528.                write1,read]] [/N]
  529.  
  530.                                       or
  531.  
  532.           device=[d:][path\]clock.sys A[,base_year] [/N]
  533.  
  534.  
  535. Parameters     d:
  536.                Identifies  the  drive  containing  CLOCK.SYS.    If  d: is not
  537.                provided, the boot drive is assumed.
  538.  
  539.           path\
  540.                Specifies  the directory containing CLOCK.SYS.  If path\ is not
  541.                given, the root directory is assumed.
  542.  
  543.           CLOCK.SYS
  544.                Is  the name of the CLOCK.SYS file.  You may change the name if
  545.                you wish, but you must not use the .COM or .EXE extensions.
  546.  
  547.           type
  548.                Is  the  kind  of calendar clock on your system.  If you do not
  549.                provide  type,  CLOCK.SYS  will  probe your system to determine
  550.                which  clock you have.  CLOCK.SYS is usually able to detect the
  551.                type  of  calendar  clock  without  trouble.    It is possible,
  552.                however,  that you have some other hardware in your system that
  553.                could  fool CLOCK.SYS.  For that reason, you might need to pro-
  554.                vide  the  type  of  clock.  See section 2.3 and Appendix B for
  555.                more information about the clock types.
  556.  
  557.           io_addr
  558.                Is  the  I/O  bus  address of your clock hardware.  Some of the
  559.                types  of  clocks  that  are  supported  were  set up at a wide
  560.                variety  of  I/O  addresses.  CLOCK.SYS probes all the commonly
  561.                used  I/O  addresses  for  these  clocks.  However, you or your
  562.                vendor  may  have  installed  your  clock  at  an  address that
  563.                CLOCK.SYS  doesn't  know  about.  By providing the address, you
  564.                make  it  much  more  likely that CLOCK.SYS will correctly find
  565.                your  clock.    Even  if  you don't know what type of clock you
  566.                have,  providing the I/O address may be enough for CLOCK.SYS to
  567.                determine  which  one  it  is.   io_addr is currently used with
  568.                clock  types  4,  6,  7, 8, 9, B, and C.  Normally this is 240,
  569.                2C0,  or  340 for types 4, 6, and 7.  It is 210 or 310 for type
  570.                9.    It  is  E0  for  type B.  And, it is 338 for type C.  All
  571.                numbers  are  in hex.  For example, an AST Research clock might
  572.  
  573.                                        8
  574.  
  575.  
  576.  
  577.  
  578.           CLOCK Version 3.70                              November 20, 1994
  579.  
  580.  
  581.                be:
  582.  
  583.                device=[d:][path\]clock.sys 4,2C0
  584.  
  585.                If  you  do  not  specify  the "io_addr", CLOCK.SYS will try to
  586.                determine the correct address by probing.
  587.  
  588.                If you are sure that you have an I/O clock but you are not sure
  589.                which  one  it  is,  specify  type  8 and supply the io_addr if
  590.                possible.   Type 8 does not represent a specific clock.  Rather
  591.                it  attempts to determine whether your clock is a type 4, 6, 7,
  592.                9, or B using a sequence of tests similar to those used by some
  593.                of  the  I/O clock vendors to figure out what kind of clock you
  594.                have.
  595.  
  596.           If  you have a memory mapped clock, you may use the second format to
  597.           specify  the addresses to be used.  If you don't know the addresses,
  598.           CLOCK.SYS will attempt to determine them by probing.
  599.  
  600.           segment
  601.                Is  the  base  address  used to access the clock.  Usually your
  602.                documentation  will give the segment address as four hex digits
  603.                such  as  FE00  or  F000.  Some addresses may be less than four
  604.                digits  (e.g.,  70).  Other documentation may show addresses in
  605.                the  form  aaaa:bbbb.   In this case the segment address is the
  606.                aaaa  value.   Sometimes these addresses are written as 0xaaaa,
  607.                aaaah,  aaaaH,  or 0Xaaaa.  In all of these forms there is a 2-
  608.                to 4-digit hex number that is the segment address.
  609.  
  610.           write0
  611.                Is  the  offset  used  to  write 0 bits.  It must also be a hex
  612.                address  and may be 0, F002, or anything else the vendor chose.
  613.                If the addresses are given in the aaaa:bbbb form, use the bbbb.
  614.                With  these clocks, you read and write the clock by reading the
  615.                memory  addresses.  For example, reading address segment:write0
  616.                results  in  writing  a  zero bit to the clock.  Writing an ap-
  617.                propriate length sequence of zero and one bits sets the clock.
  618.  
  619.           write1
  620.                Is the offset used to write 1 bits.
  621.  
  622.           read
  623.                Is the offset used to read bits.
  624.  
  625.                If your documentation gives the segment address but isn't clear
  626.                about  the  offsets,  just  specify  the  segment  address  and
  627.                CLOCK.SYS will try all offset combinations that it knows about.
  628.  
  629.                If you specify one of the offsets, you must specify them all.
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.                                        9
  638.  
  639.  
  640.  
  641.  
  642.           CLOCK Version 3.70                              November 20, 1994
  643.  
  644.  
  645.           The third format is used with the AT&T 6300 clocks.
  646.  
  647.           base_year
  648.                Is used for the AT&T 6300 clocks (type=A).  Dates prior to that
  649.                year  or  more than 7 years after that year will not be handled
  650.                correctly.    If  no base year is specified, 1992 will be used.
  651.                Dates  between  the  start  of the base year and the end of the
  652.                s e v e nth  year  later  are  handled  (e.g.,  1992-1-1  until
  653.                1999-12-31).
  654.  
  655.           /N
  656.                Indicates  that  you do not want CLOCK.SYS to attempt to detect
  657.                missed  date  changes.    Normally CLOCK.SYS will try to detect
  658.                when  a  date  has  changed  that was not reported by the BIOS.
  659.                This  usually  happens  when a program is running past midnight
  660.                and  calls  the  BIOS to read the time rather than calling DOS.
  661.                That  program sees the date-change indication from the BIOS and
  662.                DOS  (CLOCK.SYS)  never  gets  a  chance  to  change  the  day.
  663.                However,  the  logic  that  CLOCK.SYS  uses  can  be  fooled by
  664.                programs that change the time with direct calls on the BIOS and
  665.                may  advance  the  date incorrectly.  This is very rare, but if
  666.                your  date  advances  unexpectedly or by more than one day, you
  667.                may want to use this option.
  668.  
  669. Notes     DOS interfaces
  670.           All  DOS  DATE  and  TIME  commands and all DOS date and time system
  671.           calls  will  operate  with no apparent change to you or any program.
  672.           Unless  you  have  used CLK to change the time handling, your clocks
  673.           are handled just as DOS would handle them.
  674.  
  675.           Dates and leap years
  676.           CLOCK.SYS  supports all valid DOS dates from 1980-1-1 to 2079-12-31.
  677.           It  supports  dates to 2099-12-31 for many of the clocks.  CLOCK.SYS
  678.           also  handles  year  changes  and leap years automatically for clock
  679.           types that don't do it themselves.
  680.  
  681.           Time zones and daylight savings time
  682.           CLOCK.SYS  in conjunction with CLK.EXE provides support for multiple
  683.           time  zones  and  automatic conversion between daylight savings time
  684.           and  standard  time  at the appropriate times of the year.  For this
  685.           reason, CLOCK.SYS may be of great use to you even if your version of
  686.           DOS already supports your clock correctly.
  687.  
  688.           Clock synchronization
  689.           Normally,  CLOCK.SYS  operates  identically to the DOS CLOCK$ device
  690.           driver.  At boot it sets the DOS clock from the calendar clock.  Any
  691.           time you change the date or time it writes to both clocks.
  692.  
  693.           With  CLK.EXE you have several other options.  If you have specified
  694.           a time zone and offset with CLK.EXE, CLOCK.SYS will adjust all times
  695.           read from and written to the calendar clock by the time zone offset.
  696.           You  can  also set it to read the calendar clock rather than the DOS
  697.           c l o c k  for  some  or  all  time  requests  to  ensure  continued
  698.           synchronization  of  the  two clocks.  You can also totally separate
  699.           the  two  clocks  so  that DOS time and date functions only read and
  700.  
  701.                                       10
  702.  
  703.  
  704.  
  705.  
  706.           CLOCK Version 3.70                              November 20, 1994
  707.  
  708.  
  709.           write the DOS/BIOS internal clock.
  710.  
  711.           Time setting limits
  712.           CLK.EXE  can tell CLOCK.SYS to apply limits to the time changes that
  713.           it  will accept or stop accepting time changes at all.  For example,
  714.           you can tell CLOCK.SYS to accept no changes that would set the clock
  715.           backward.  You can also inhibit all changes.
  716.  
  717.           Password Protection
  718.           CLK.EXE  can  establish  a password to control future changes to the
  719.           time  zone,  connection, and time setting limits.  Once the password
  720.           is  set,  all attempts to change those values will simply be ignored
  721.           unless  the  correct  password  is  supplied.    You  may change the
  722.           daylight  versus  standard time flag and the continuous time display
  723.           without knowing the password.
  724.  
  725.           Continuous Time Display
  726.           CLK.EXE can tell CLOCK.SYS to display the date and time continuously
  727.           at any position on your screen.  You specify the cursor coordinates,
  728.           display  attributes,  and 12-hour or 24-hour mode and CLOCK.SYS will
  729.           update the display every second.  The date display is optional.
  730.  
  731.           Saving Settings Across Boots
  732.           With CLK.EXE you can save the current state of CLOCK.SYS at any time
  733.           in  a  form that can be used on your next boot.  You can set up your
  734.           time  zone, setting limits, connection mode, continuous display, and
  735.           password and then save a new version of CLOCK.SYS.  This new version
  736.           will  automatically  start  running  with without having to scan for
  737.           your  clock  type  and with all your standard state automatically in
  738.           effect.
  739.  
  740. 2.3  Clock Type
  741.  
  742. There  are  almost as many different implementations of PC clocks as there are
  743. different types of PCs.  Until the PC/AT came along, there was no standard for
  744. battery-protected  clocks,  and  each  PC  and  add-in  vendor  was  likely to
  745. implement  them  differently.    With  the  PC/AT  a  standard  and documented
  746. interface  for  such  clocks  was  provided.    Since that time, most PCs have
  747. followed  the  PC/AT  standard.   It is earlier PCs, especially 8088 PCs, that
  748. don't  follow  the  standard.  Since these are early PCs, there is also a high
  749. probability  that  the  vendor is no longer providing modified versions of DOS
  750. with  built-in  support for their clocks.  Most add-in clock vendors never did
  751. provide a modified DOS and you had to manage your clock with utility programs.
  752. This leaves you faced with the choice between staying with an early version of
  753. DOS or giving up your clock.
  754.  
  755. CLOCK.SYS  is  intended to free you from those limitations.  It will work with
  756. all  versions  of  DOS from 2.10 through 6.20 and undoubtedly beyond.  It also
  757. attempts  to  automatically  determine what kind of clock you have and install
  758. the  correct  support  for  it.    However, there are often enough differences
  759. between PCs that the automatic determination may not find anything or may even
  760. make  the  wrong  choice.   To give you more control of the situation, you may
  761. specify the clock interface by giving an interface number.
  762.  
  763. It  will  not always be easy to decide what interface number to use.  You will
  764.  
  765.                                       11
  766.  
  767.  
  768.  
  769.  
  770.           CLOCK Version 3.70                              November 20, 1994
  771.  
  772.  
  773. at  least  need  some  technical information on how your clock works or on the
  774. BIOS  calls  used  to  control  the  battery-protected  clock.   If you find a
  775. description below that seems to match, give it a try.  The most that should go
  776. wrong is that your time and date will be set incorrectly, but then they proba-
  777. bly weren't working anyhow.
  778.  
  779. If you aren't sure what interface to use or if you are sure that your clock is
  780. not  supported,  LET  ME  KNOW.    I WOULD LIKE TO HELP.  You can help me make
  781. CLOCK.SYS  better  for  everyone.    I  would  even  like  to hear from you if
  782. CLOCK.SYS  did  work  for  you and your clock isn't currently listed.  I would
  783. like  to be able to add your PC manufacturer and model number to the supported
  784. list  so  others  know  what  to use.  If CLOCK.SYS did not work for you, I am
  785. interested  in making the changes so that it does work.  If you can provide me
  786. with the necessary technical information, I will make the changes.
  787.  
  788. Usually, a technical reference manual with hardware and BIOS interfaces is the
  789. best source.  Even if you don't have one, your original hardware vendor may be
  790. willing  to send you enough information to allow you to program the clock.  If
  791. all  else  fails,  we  may  even  be able to use an old copy of DOS or a clock
  792. setting  utility  to  figure  out how it works.  Before we do that, check your
  793. license to be sure that it is not forbidden to disassemble the software to see
  794. how the clock works.  
  795. The  following  table shows the systems that have been determined to work with
  796. existing  clock  types.    If  your  system is in the list, try the clock type
  797. indicated.   If not, look through Appendix B which tells you about the charac-
  798. teristics of each type of clock and see if anything seems to match your system
  799. type.
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.                                       12
  830.  
  831.  
  832.  
  833.  
  834.           CLOCK Version 3.70                              November 20, 1994
  835.  
  836.  
  837.  
  838.      ╔═══════════════════════════╤══════════════════════════╗
  839.      ║         SYSTEM            │       CLOCK TYPE         ║
  840.      ╟───────────────────────────┼──────────────────────────╢
  841.      ║     Amstrad PC1521DD      │  0                       ║
  842.      ╟───────────────────────────┼──────────────────────────╢
  843.      ║     AST Research          │  8 (4, 6, or 7) See dis- ║
  844.      ║       Six-Pack            │  cussion above and in    ║
  845.      ║       I/O Plus            │  Appendix B              ║
  846.      ║       etc.                │                          ║
  847.      ╟───────────────────────────┼──────────────────────────╢
  848.      ║     AT&T 6300             │  A                       ║
  849.      ╟───────────────────────────┼──────────────────────────╢
  850.      ║     Hyundai 8088          │  B                       ║
  851.      ╟───────────────────────────┼──────────────────────────╢
  852.      ║     IBM PC/AT and most    │  0                       ║
  853.      ║     PCs since then.       │                          ║
  854.      ╟───────────────────────────┼──────────────────────────╢
  855.      ║     Leading Edge Model D  │  5                       ║
  856.      ╟───────────────────────────┼──────────────────────────╢
  857.      ║     Mitsubishi 8088       │  5                       ║
  858.      ╟───────────────────────────┼──────────────────────────╢
  859.      ║     Multi I/O Card        │  C                       ║
  860.      ╟───────────────────────────┼──────────────────────────╢
  861.      ║     NEC MultiSpeed        │  0                       ║
  862.      ╟───────────────────────────┼──────────────────────────╢
  863.      ║     Quadram Corp.         │  9                       ║
  864.      ║       QuadCard            │                          ║
  865.      ║       QuadCard II         │                          ║
  866.      ║       QuadCard 512+       │                          ║
  867.      ╟───────────────────────────┼──────────────────────────╢
  868.      ║     SMT No-Slot Clock     │  3                       ║
  869.      ╟───────────────────────────┼──────────────────────────╢
  870.      ║     Sperry PC-1           │  5                       ║
  871.      ╟───────────────────────────┼──────────────────────────╢
  872.      ║     Sperry PC/HT          │  5                       ║
  873.      ╟───────────────────────────┼──────────────────────────╢
  874.      ║     Tandy 1200HD          │  4                       ║
  875.      ╟───────────────────────────┼──────────────────────────╢
  876.      ║     Vendex Turbo-888-XT   │  4                       ║
  877.      ╟───────────────────────────┼──────────────────────────╢
  878.      ║     Zenith Supersport 20  │  1                       ║
  879.      ╟───────────────────────────┼──────────────────────────╢
  880.      ║     Zenith Z-18x          │  1                       ║
  881.      ╚═══════════════════════════╧══════════════════════════╝
  882.  
  883.  
  884. 2.4  Examples
  885.  
  886. For almost everyone, the only format you ever need to use is:
  887.      device=[d:][path\]clock.sys
  888.  
  889. If CLOCK.SYS is in the root directory of your boot device, this is:
  890.      device=clock.sys
  891.  
  892.  
  893.                                       13
  894.  
  895.  
  896.  
  897.  
  898.           CLOCK Version 3.70                              November 20, 1994
  899.  
  900.  
  901. CLOCK.SYS will quite happily load into the upper memory blocks (UMBs) provided
  902. by DOS 5.0 and by other software.  With DOS 5.0, you might use:
  903.      devicehigh=clock.sys
  904.  
  905. With some memory managers you can even load CLOCK.SYS into upper memory blocks
  906. on  earlier  levels of DOS.  See your manual for the commands to use.  Some of
  907. these  memory  managers will create UMBs on 8088 and 80286 systems.  CLOCK.SYS
  908. loads and runs high on those systems as well.
  909.  
  910. With  a  memory  mapped  clock that uses an address combination that CLOCK.SYS
  911. doesn't  search  automatically and with CLOCK.SYS stored in the C:\UTILITY di-
  912. rectory, you might use:
  913.      device=c:\utility\clock.sys 3,ffff,f000,f004,f008
  914. Please  note  that the memory addresses chosen for this example are not likely
  915. to  match  those  of  your  clock  and  you  should  substitute  the addresses
  916. appropriate to your clock.
  917.  
  918. If  you  have  an I/O clock with the same interface as the Quadram Corp. clock
  919. but a different I/O address, you might use:
  920.      device=clock.sys 9,3fc
  921. if your I/O base address were 3fc.
  922.  
  923. If you have one of the AT&T 6300 system types and you occasionally need to set
  924. your clock prior to 1992-1-1, you might use:
  925.      device=clock.sys a,1988
  926.  
  927. 2.5  Future Enhancements
  928.  
  929. Of  course,  I  hope to add more clocks as people ask for them.  Those old PCs
  930. are still good for a lot of what we do even if they are sometimes relegated to
  931. a secondary status.
  932.  
  933. There are no other outstanding enhancements currently planned for CLOCK.SYS.
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.                                       14
  958.  
  959.  
  960.  
  961.  
  962.           CLOCK Version 3.70                              November 20, 1994
  963.  
  964.  
  965. 3.  CLK.EXE - Clock Control Program
  966.  
  967. CLK  gives  you  complete control over the operation of the calendar clock and
  968. DOS/BIOS  clock.  You can operate them separately or together.  You can estab-
  969. lish time zones, daylight savings time rules, automatic adjustment, synchroni-
  970. zation rules, and more.
  971.  
  972.  
  973. 3.1  CLK Command
  974.  
  975. Syntax    clk [function] [function ...] [/I[file]] [/?]
  976.  
  977.                     or in full form
  978.  
  979.           clk [A=±sss.cc] [C=A|D|R|W] [D=[N][x,y,a[,[12|24][,D]]]
  980.                [L=...] [M=...] [R=A|B-hh:mm:ss|F+hh:mm:ss|N|R]
  981.                [S=C|D]   [TZ=...]   [W=-back,+forward]   [/B]   [/I[file][,C]]
  982.                [/M[file][,C]] [/P[N]] [/S[file]] [/?]
  983.  
  984. Parameters     function
  985.                There are many functions that may be used with CLK.EXE and they
  986.                are  discussed  in  the  following paragraphs.  You may use any
  987.                number  of  functions on a single command line and they will be
  988.                processed  in  the  order in which you enter them.  However, if
  989.                any  error  is discovered in any of the functions, none of them
  990.                are processed.  Thus, 
  991.                     clk c=r tz=:est
  992.                is the same as the two command lines:
  993.                     clk c=r
  994.                     clk tz=:est
  995.                except  that  an  error in either of the functions in the first
  996.                example cause the whole command to be ignored.
  997.  
  998.                The  case  (upper  or  lower)  of  any  of  the function names,
  999.                options, or values is ignored except for the TZ function's time
  1000.                zone  names.    Even there, the case is not used.  It is simply
  1001.                preserved for later display.
  1002.  
  1003.                You  can display a help message about any function or option by
  1004.                immediately following the function letter or option letter with
  1005.                ?.    Thus  M?  displays  help  about  the  M= function and /I?
  1006.                displays  help  about the I option.  /? displays a help message
  1007.                about the CLK command line.
  1008.  
  1009.           none
  1010.                If  no function or option is provided, CLK displays the current
  1011.                state  of operation of CLOCK.SYS and the current time from both
  1012.                the calendar clock and the DOS/BIOS clock.
  1013.  
  1014.                If  you  have  used  CLK  to set a time zone (TZ function), the
  1015.                current  time  zone name and offset value are displayed.  These
  1016.                values are saved in CLOCK.SYS so that they may be used for time
  1017.                functions.
  1018.  
  1019.                The connection state of the clocks (C function) is displayed as
  1020.  
  1021.                                       15
  1022.  
  1023.  
  1024.  
  1025.  
  1026.           CLOCK Version 3.70                              November 20, 1994
  1027.  
  1028.  
  1029.                is the current restrictions (R function) on clock changes.
  1030.  
  1031.                All  uses  of  CLK (except errors and /?) end by displaying the
  1032.                same information.  You always know the state of your two clocks
  1033.                after execution.
  1034.  
  1035.           A=±sss.cc
  1036.           or
  1037.           A=M
  1038.                The Adjust function is used to set a daily adjustment factor in
  1039.                seconds and 100ths of seconds.
  1040.  
  1041.                This  function assumes that you have some knowledge of the rate
  1042.                at  which  your  calendar  clock  drifts with respect to "real"
  1043.                time.   Presumably you have periodically set your clock using a
  1044.                program  that calls the Naval Observatory or NIST and noted the
  1045.                difference  over  time.    Some  such programs will help you to
  1046.                calculate  the  drift rate.  You can get a very good adjustment
  1047.                from a decent quartz watch.
  1048.  
  1049.                The  value  may be a positive or negative number in the range -
  1050.                326.99  to  +326.99  seconds  per day but reasonable values are
  1051.                likely to be a fraction of a second.
  1052.  
  1053.                The  first  time  you  use A=, your clock is not adjusted.  The
  1054.                value  of  A and the current time are saved in a file for later
  1055.                use.    Later  you  can choose to run CLK with the /I option to
  1056.                invoke  the  file.   The elapsed time since the last adjustment
  1057.                (or  the  time  you  last  changed  A) in days and fractions is
  1058.                multiplied  by  A  to calculate any adjustment that needs to be
  1059.                applied.  Only whole seconds of adjustment are applied.
  1060.  
  1061.                The  A=  function  only sets the adjustment factor.  The actual
  1062.                adjustment  is  carried out by the L= function.  You don't have
  1063.                to  enter  the L= function.  CLK will do that for you the first
  1064.                time  you  use A= and will keep it up to date as it later makes
  1065.                adjustments.
  1066.  
  1067.                If  you  have  been  calculating  a  new adjustment with the M=
  1068.                function,  you can apply the new calculated value by specifying
  1069.                A=M  on the command line.  We don't automatically apply the new
  1070.                calculated value until you use the A= function because we don't
  1071.                know when you are satisfied with the calculation.
  1072.  
  1073.                NOTE:    Do  not  use the A= function with the AT&T 6300 clocks
  1074.                (Type  A) or the Quadram clocks (Type 9).  They only permit the
  1075.                time to be set to the nearest minute.
  1076.  
  1077.           C=A
  1078.                Connects   the  two  clocks  for  All  operations.    All  read
  1079.                operations  go  directly  to the calendar clock.  The calendard
  1080.                clock  is  read, the time is adjusted for any time zone offset,
  1081.                and  the adjusted time is written to the DOS clock and returned
  1082.                to  the  caller.    With this function, your calendar clock es-
  1083.                sentially  becomes  the  only clock.  However, the DOS clock is
  1084.  
  1085.                                       16
  1086.  
  1087.  
  1088.  
  1089.  
  1090.           CLOCK Version 3.70                              November 20, 1994
  1091.  
  1092.  
  1093.                set  each  time  so  that any application reading the clock di-
  1094.                rectly  (without going through DOS) sees the same time that DOS
  1095.                reports.    It  is unwise to use this function if your clock is
  1096.                slow  (some  I/O clocks and some memory-mapped clocks) or if it
  1097.                only  increments  in  units of seconds (most clocks).  Any time
  1098.                zone offset is applied to reads and writes.
  1099.  
  1100.           C=D
  1101.                Disconnects  the  two  clocks.  Any change of the date and time
  1102.                will  affect  the DOS clock only.  Reads also use the DOS clock
  1103.                only.  This function allows you to perform any operation on the
  1104.                time  without  affecting your calendar clock.  It is useful for
  1105.                dealing  with ill-behaved programs that need to change the time
  1106.                and for testing programs at different dates and times.  You can
  1107.                later  use the C=R, C=A, or other functions to re-establish the
  1108.                value in your DOS clock from the calendar clock.
  1109.  
  1110.           C=R
  1111.                Connects the two clocks for writing and periodic Reading.  This
  1112.                function may be used when your clocks drift slowly with respect
  1113.                to each other.  If the time has not been read for about 10 sec-
  1114.                onds,  the  calendar clock will be read, adjusted by the offset
  1115.                if  any, and the adjusted time written to the DOS clock and re-
  1116.                turned  to the caller.  This periodic Read assures you that the
  1117.                clocks  never  get  very  far  out of synchronization with each
  1118.                other.    Some  calendar  clocks take a relatively long time to
  1119.                read  and  most  don't have 100ths of seconds.  By only reading
  1120.                the  calendar  clock when no other time request has occurred in
  1121.                the  last  10  seconds,  we  minimize both the overhead and any
  1122.                visibility of time jumps.
  1123.  
  1124.           C=W
  1125.                Connects  the two clocks for Writing.  This is the default mode
  1126.                of  operation  and  is the same mode that the DOS CLOCK$ device
  1127.                driver  supports  as its only mode.  Reading the time is served
  1128.                by  the  DOS  clock.   Writing the time sets both clocks.  If a
  1129.                time  zone  offset has previously been specified, all writes to
  1130.                the  clock  are  adjusted so that the calendar clock remains on
  1131.                the  base  time.   For example, if the calendar clock is set to
  1132.                UTC  and  you  specify  that  you  want to use CST which has an
  1133.                offset  of 6 hours from UTC, all writes of the time will have 6
  1134.                hours added to them before writing to the calendar clock.  Thus
  1135.                the  DOS clock and the calendar clock remain at a constant time
  1136.                offset.
  1137.  
  1138.           D=N
  1139.                The  D= function controls a continuous time display.  D=N turns
  1140.                off the continuous display.
  1141.  
  1142.           D=x,y,a[,[12|24][,D]]
  1143.                Starts  a  continuous  time display at cursor position x,y with
  1144.                display  attribute  a.    Cursor position 0,0 is the upper left
  1145.                corner  of the screen.  The typical screen format runs from 0,0
  1146.                to 79,24.  The display attribute is a two-digit hex number that
  1147.                gives  the  background  and  foreground colors.  The high-order
  1148.  
  1149.                                       17
  1150.  
  1151.  
  1152.  
  1153.  
  1154.           CLOCK Version 3.70                              November 20, 1994
  1155.  
  1156.  
  1157.                digit  is  the  background  color (0 to 7 usually) and the low-
  1158.                order digit is the foreground or character color (0 to F).  The
  1159.                default  display  is  a 24-hour clock in the form HH:MM:SS.  If
  1160.                you add the ",12", the display will use a 12-hour clock.  No AM
  1161.                or  PM  indication  is  given.  If you add a D option after the
  1162.                time  selection,  the  date  is displayed in YY-MM-DD format in
  1163.                front of the time.
  1164.  
  1165.                D=63,24,79,12,d will place the display at the right edge of the
  1166.                last  line of most screens.  The text will be in bright blue on
  1167.                a white background and the hours will run from 12 through 11.
  1168.  
  1169.                D= by itself will resume a previous display that was turned off
  1170.                by D=N.  You do not have to re-enter all the values.
  1171.  
  1172.                The  D=  functions  should  not be used if CLK is executed from
  1173.                within  Windows.    If  you  try to do so, you will received an
  1174.                error message.  This avoids a hung system which would otherwise
  1175.                occur  as  Windows  will  not  support  programs  which  change
  1176.                interrupt vectors.
  1177.  
  1178.           L=YYYY-MM-DD,hh:mm:ss,±sss.cc
  1179.  
  1180.                The L= function is not intended to be used on the command line,
  1181.                but  will  be  accepted  if you provide it.  The L= function is
  1182.                normally created by CLK and saved in the CLK.INI file for later
  1183.                use  in  processing adjustments.  The date and time of the last
  1184.                adjustment  (or the most recent time you gave an A= function on
  1185.                the  command  line)  are given by the YYYY-MM-DD,hh:mm:ss.  Any
  1186.                non-digit except a space may separate the sub-fields.  The date
  1187.                and  time  must  be  followed  by  a  comma  and any adjustment
  1188.                remainder.  The adjustment remainder is in the same form as the
  1189.                value  for  the A= function but will usually be a fraction of a
  1190.                second.   It is the adjustment that was left over the last time
  1191.                an  adjustment  was  actually  made since only whole seconds of
  1192.                changes are made to the clock.
  1193.  
  1194.                The  L=  function triggers an adjustment if needed.  Generally,
  1195.                it will follow the A= function that sets the adjustment factor.
  1196.                Both of these functions normally appear in the CLK.INI file.
  1197.  
  1198.                The  L=  function  may  also  be  used  by  itself to do simple
  1199.                arithmetic  on the clocks.  Use it on the command line with any
  1200.                earlier  date  and  time  and  an  adjustment  of the number of
  1201.                seconds  (positive  or  negative)  that  you  want added to the
  1202.                clock.    The  change will be made and the last adjustment time
  1203.                set to the current time.  For example, 
  1204.                     clk l=1990-1-1,0:0:0,-4
  1205.                will subtract 4 seconds from the clocks.
  1206.  
  1207.           M=±sss.cc,YYYY-MM-DD,hh:mm:ss
  1208.           or
  1209.           M=LAST
  1210.                The  M=  function  is  used to help you calculate the automatic
  1211.                adjustment  A=  value for your calendar clock.  The M= function
  1212.  
  1213.                                       18
  1214.  
  1215.  
  1216.  
  1217.  
  1218.           CLOCK Version 3.70                              November 20, 1994
  1219.  
  1220.  
  1221.                is  used  to  enter the manual adjustments that you make to the
  1222.                clock in addition to the automatic adjustments.  The ±sss.cc is
  1223.                the  amount  of manual adjustment that you have made.  This may
  1224.                be  adjustments made by setting the clock with the DOS DATE and
  1225.                TIME  commands  or  adjustments made by a time setting program.
  1226.                The  YYYY-MM-DD,hh:mm:ss  is  the  date  and  time at which the
  1227.                adjustment  was  made.   It is very important that the date and
  1228.                time  be  given  with respect to the calendar clock and not the
  1229.                DOS  clock,  if  different.   If you do not supply the date and
  1230.                time,  the  current date and time will be used.  This should be
  1231.                s u fficiently  accurate  if  you  just  completed  making  the
  1232.                adjustement.
  1233.  
  1234.                M=LAST  is the easiest way to input the changes and the time of
  1235.                last  change.    Whenever you set a new date or time, CLOCK.SYS
  1236.                saves the time immediately before setting the new value and the
  1237.                new  value.    M=LAST uses those two values to calculate the M=
  1238.                function  for  you.  This even works if you are using a program
  1239.                to dial a time source.
  1240.  
  1241.                The  first  M=  value that you enter is used only to set a base
  1242.                date  and  time.    Then  as you enter additional values in the
  1243.                future,  CLK  will calculate a new value for the A= function by
  1244.                adding  the average manual adjustment per day to the current A=
  1245.                value.   Up to 8 values are saved in the CLK.INI file (or other
  1246.                file  that  you  specify).  The more values you provide and the
  1247.                longer  the  time period, the more accurate the adjustment will
  1248.                be.    For example, if you can only determine the adjustment to
  1249.                the  nearest  second  (likely),  you may want to have a week or
  1250.                more  between manual adjustments.  The only restriction is that
  1251.                the  first  and last manual adjustement must be within one year
  1252.                of  each  other.    If  you  enter  more than 8, the oldest two
  1253.                adjustement values are collapsed into a single value.
  1254.  
  1255.                Supplying  a new A= value, presumably based on the calculations
  1256.                from  CLK,  deletes  all  the M= values from the file.  You may
  1257.                either specify a /I option to specify the file and read all the
  1258.                functions in the file, a /M option to specify the file and only
  1259.                read the M= functions, or CLK will automatically specify the /M
  1260.                option  for  you  (but it will only know to look for CLK.INI in
  1261.                the  directory  containing  CLK.EXE).  You may also edit the M=
  1262.                functions  in  the  file  and  use the /M option to force a re-
  1263.                calculation.
  1264.  
  1265.                When  CLK  calculates  a  new  adjustment  value,  it  tries to
  1266.                determine if any of the M= values are out of line with the rest
  1267.                of  the  values.  It will ignore, but provide an error message,
  1268.                if  any  of the values are too far away from all of the others.
  1269.                CLK  calculates  an  average and standard deviation and ignores
  1270.                all  values  (of  adjustment  per  day)  that  are  more than 2
  1271.                standard deviations from the average.
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.                                       19
  1278.  
  1279.  
  1280.  
  1281.  
  1282.           CLOCK Version 3.70                              November 20, 1994
  1283.  
  1284.  
  1285.           R=A
  1286.                The  R=  function  sets  restrictions  on  time  changes.   R=A
  1287.                inhibits All time changes.  When this mode is set, all attempts
  1288.                to  change  the  time  are ignored by CLOCK.SYS.  This includes
  1289.                time  changes attempted by CLK including time adjustments.  See
  1290.                R=N.
  1291.  
  1292.           R=B-hh:mm:ss
  1293.                This function limits the amount of Backward change of the time.
  1294.                Any change of more than the specified time is ignored.  The "-"
  1295.                is optional as are the offset fields.
  1296.                     clk r=b
  1297.                inhibits all backward changes.
  1298.                     CLK R=B::2
  1299.                only  allows backward changes of two seconds or less This might
  1300.                permit  CLK  to  perform adjustments but effectively stop other
  1301.                backward changes.
  1302.  
  1303.           R=F+hh:mm:ss
  1304.                This  function limits the amount of Forward change of the time.
  1305.                Any change of more than the specified time is ignored.  The "+"
  1306.                is optional as are the offset fields.
  1307.                     CLK R=F+1:00:02
  1308.                limits  forward  changes  to 1 hour and 2 seconds.  The R=B and
  1309.                R=F  limits  do  not apply to the automatic conversions between
  1310.                standard  and  daylight  savings  time  as these don't actually
  1311.                change  the  time.  The R=B and R=F functions are also indepen-
  1312.                dent of the R=A function.
  1313.  
  1314.           R=N
  1315.                This  function  reverses the R=A function and inhibits No clock
  1316.                changes.    The R=A is independent of the R=B and R=F.  You can
  1317.                set  backward  and  forward limits with R=B and R=F.  Later you
  1318.                can  inhibit all changes with R=A.  When you do R=N, the previ-
  1319.                ously set R=B and R=F limits again have an effect.
  1320.  
  1321.           R=R
  1322.                This function Resets the limits established by R=B and R=F.  No
  1323.                limits  are in effect after executing this function.  It has no
  1324.                effect on the R=A mode.
  1325.  
  1326.           S=C
  1327.                Sets  both  clocks to the current time from the calendar clock.
  1328.                You  can  use  this even if the clocks are disconnected to make
  1329.                the  DOS  clock  equal  to  the  calendar clock.  The time zone
  1330.                offset  is set to 00:00:00 and the time zone name is set to UTC
  1331.                to indicate that both clocks are set to the base time.
  1332.  
  1333.           S=D
  1334.                Sets  both  clocks to the current time from the DOS clock.  The
  1335.                value from the DOS clock is written to the calendar clock.  The
  1336.                time  zone  offset  is set to 00:00:00 and the zone name is not
  1337.                changed  to  indicate  that  both  clocks are set to your local
  1338.                time.
  1339.  
  1340.  
  1341.                                       20
  1342.  
  1343.  
  1344.  
  1345.  
  1346.           CLOCK Version 3.70                              November 20, 1994
  1347.  
  1348.  
  1349.           TZ=...
  1350.                Sets the DOS clock to the correct local time based on the value
  1351.                of  the expression following the TZ=.  This expression conforms
  1352.                exactly  to  the  POSIX 1003.1 standard for time zone handling.
  1353.                CLK  assumes  that  the  calendar  clock currently contains UTC
  1354.                (also  known  as  GMT,  Greenwich,  ZULU,  and  Z  time).   UTC
  1355.                ("Universal   Time,   Coordinated"   is   usually   spoken   as
  1356.                "coordinated  universal time") is the name of the international
  1357.                standard  time  that  is  provided  by  WWV,  WWVH,  the  Naval
  1358.                Observatory, and NIST as well as many other services around the
  1359.                world.    Most  Unix systems also support TZ although many only
  1360.                partially  support the POSIX standard.  See the notes later for
  1361.                a complete description of the TZ= function.
  1362.  
  1363.                You  can  put the CLK TZ=... command in your AUTOEXEC.BAT file.
  1364.                You should put it prior to any other statements that may create
  1365.                or  update  files or you run the risk of having confusing times
  1366.                in  your  file directory (MAKE could get especially confused.).
  1367.                If  you  provide a TZ= function, your system will automatically
  1368.                adjust to the correct time zone every time you boot.  Note that
  1369.                no attempt is made to change between daylight and standard time
  1370.                except  when  you  execute  CLK TZ=...  Adjusting on the fly is
  1371.                very dangerous.  Many programs can produce incorrect results or
  1372.                even corrupt your data if time takes a big step forward and are
  1373.                even  more  likely to do so if time runs backward.  See section
  1374.                3.4, 3.4 for a discussion of the TZ= format.
  1375.  
  1376.  
  1377.           W=-back,+forward
  1378.                The  W=  function  is  used  to establish Warning limits on the
  1379.                time.  Each time the W= function is processed (usually from the
  1380.                CLK.INI  file),  the  current  time  and  the previous time are
  1381.                compared.    If  the current time is outside the -back,+forward
  1382.                range  around the previous time, a warning message is displayed
  1383.                requiring  you to press a key.  The program will also exit with
  1384.                an ERRORLEVEL of 1.  The full form of the W= function is:
  1385.                W=N-days/hh:mm:ss,+days/hh:mm:ss,
  1386.                     YYYY-MM-DD,hh:mm:ss
  1387.  
  1388.                The  days  sub-field  is  a value from 0 to 250 days.  The days
  1389.                sub-field  combined  with the time sub-fields gives the maximum
  1390.                interval around the previous time within which the current time
  1391.                must fall.  The previous date and time follow the second comma.
  1392.                For example,
  1393.                     clk w=-0/00:00:02,+91
  1394.                will  establish  a  range of minus two seconds to plus 91 days.
  1395.                The first time you use this function nothing will happen except
  1396.                that  CLK will add the current date and time to the command and
  1397.                store  it  in  the CLK.INI file.  The next time you use if from
  1398.                the CLK.INI file with CLK /I, the current date and time will be
  1399.                compared  to  the previous date and time and the range.  If the
  1400.                current  time  is outside the range, a message is displayed and
  1401.                CLK pauses.
  1402.  
  1403.                The  sign  characters  and  all of the sub-fields are optional.
  1404.  
  1405.                                       21
  1406.  
  1407.  
  1408.  
  1409.  
  1410.           CLOCK Version 3.70                              November 20, 1994
  1411.  
  1412.  
  1413.                Missing  sub-fields  are  treated  as  zero.    The  particular
  1414.                separators  are  not important except for the commas.  Any non-
  1415.                digit character can be used for the other separators.  The time
  1416.                and  date  fields  are appended to the function by CLK when the
  1417.                CLK.INI  file is written and are the previous time to which the
  1418.                next  comparison  will  be  made.   A typical function might be
  1419.                W=,31.    This command will display a warning whenever time has
  1420.                moved  backwards  at  all or has moved forwards by more than 31
  1421.                days  since  the  last time you used CLK /I.  If you use CLK /I
  1422.                (see  below)  in your AUTOEXEC.BAT file, this is very likely to
  1423.                detect  a  miss-set  clock  or bad clock battery.  Yet it won't
  1424.                generate  a  message  on  every  boot.  You  will  only  get an
  1425.                "unnecessary"  message  if  it has been more than a month since
  1426.                you last used the PC.
  1427.  
  1428.                If  the  "N"  character  (or "n") appears immediately after the
  1429.                "=",  CLK  does not pause and wait for you to press a key after
  1430.                printing the warning message.  The "N" allows you to use CLK in
  1431.                a  .BAT  file  and check for the warning with the IF ERRORLEVEL
  1432.                command.
  1433.  
  1434.           /B
  1435.                The  B  option  tells  CLK to remain in command mode even if no
  1436.                other  functions  or  options  are  present.   The /B in itself
  1437.                performs no operation, but it avoids CLK going into full-screen
  1438.                mode if all you want to do is display the current status (e.g.,
  1439.                in a .BAT file).
  1440.  
  1441.           /I[,C]
  1442.           or
  1443.           /Ifile[,C]
  1444.                The  I  option tells CLK to read the CLK.INI file (or "file" if
  1445.                that  is  given) for additional functions.  These functions are
  1446.                usually  A=,  L=, and W= functions that were previously written
  1447.                to  the  file  by CLK.  You may add any other functions (but no
  1448.                options)  to  the file and they will be processed as if you had
  1449.                entered  them  at  the  end  of the command line.  If you don't
  1450.                specify  "file" or you don't give a path as part of "file", CLK
  1451.                will  use  the  directory which contains CLK.EXE.  Thus the de-
  1452.                fault is to use CLK.INI in the directory that contains CLK.EXE.
  1453.  
  1454.  
  1455.                If you enter an A=, L=, M=, or W= function or CLK finds them in
  1456.                the  file, the file will be updated with the new values for the
  1457.                current  time  when appropriate.  If an adjustment is made, the
  1458.                L=  function  will  reflect  the  date  and  time of the latest
  1459.                adjustment.    CLK will update or create a CLK.INI file even if
  1460.                you  don't  use  the /I option if you use the A=, L=, M=, or W=
  1461.                functions on the command line.
  1462.  
  1463.                It  is  very  useful  to  store  your  standard TZ=, C=, and R=
  1464.                functions in the CLK.INI file.  Then your AUTOEXEC.BAT file can
  1465.                simply  contain  a CLK /I command to set your clocks into their
  1466.                standard  modes,  adjust  the  time,  and  check  for bad clock
  1467.                values.    You  can  also reestablish your standard modes after
  1468.  
  1469.                                       22
  1470.  
  1471.  
  1472.  
  1473.  
  1474.           CLOCK Version 3.70                              November 20, 1994
  1475.  
  1476.  
  1477.                changes  with the same command entered from the DOS prompt or a
  1478.                .BAT file.
  1479.  
  1480.                The  file  may  be  hidden  and still be updated without error.
  1481.                However, to update a read-only file, you must add ,C to the end
  1482.                of  the  option.    This  indicates  that  CLK  may  Change the
  1483.                attributes of the file in order to update it.  CLK will restore
  1484.                the original attributes.  System files may not be updated.
  1485.  
  1486.           /M[,C]
  1487.           or
  1488.           /Mfile[,C]
  1489.                The  M option is identical to the I option except that only the
  1490.                M=  function  lines are read from the file.  Its primary use is
  1491.                internal to CLK when processing an M= function from the command
  1492.                line.    You may also use /Mfile to specify the location of the
  1493.                file when entering M= values.  You may also use the M option to
  1494.                cause recalculation of the adjustment factor at any time (e.g.,
  1495.                after editing the file).
  1496.  
  1497.           /P
  1498.           or
  1499.           /PN
  1500.                Controls  the use of password protection of mode changes.  When
  1501.                you  use /P, CLK will ask you for a new password.  It will then
  1502.                ask  you to repeat the password to ensure that you entered what
  1503.                you  want.    It does not display the password as you enter it.
  1504.                T h e  password  is  then  passed  to  CLOCK.SYS  and  password
  1505.                protection  is enabled.  On future calls to CLOCK.SYS, you will
  1506.                be  asked  for  the password if protection is enabled.  You may
  1507.                use  /PN  to  disable password protection, but you will have to
  1508.                provide  the  current  password  to do so.  If used with the /S
  1509.                feature,  the  password  protection  will remain in effect even
  1510.                across  reboots.   /P should be the last field on a CLK command
  1511.                line.
  1512.  
  1513.           /S
  1514.           or
  1515.           /Sfile
  1516.                Saves  the  current  copy of CLOCK.SYS as it resides in memory.
  1517.                If  you  do not specify the file, the memory version is written
  1518.                to  file CLOCK.NEW in the same directory that contains CLK.EXE.
  1519.                While you may directly overwrite the file CLOCK.SYS, you should
  1520.                be very careful doing so as whatever your current state is will
  1521.                take effect on the next boot.
  1522.  
  1523.                PLEASE  MAKE  A  BACKUP  COPY of your original CLOCK.SYS before
  1524.                replacing it with a saved file.  The saved file does not do any
  1525.                probing  at  boot  time  as  it already knows exactly what your
  1526.                clock  is.  It does not need any parameters on the device= line
  1527.                in CONFIG.SYS.
  1528.  
  1529.                The  /S option may be extremely useful for anyone with multiple
  1530.                similar  systems  to  maintain.    You  can  set up all of your
  1531.                options once on one machine, save those with the /S option, and
  1532.  
  1533.                                       23
  1534.  
  1535.  
  1536.  
  1537.  
  1538.           CLOCK Version 3.70                              November 20, 1994
  1539.  
  1540.  
  1541.                then  use  the  saved file to directly install on all the other
  1542.                machines.    If  you use password protection, no one can change
  1543.                the  other systems except by modifying CONFIG.SYS to remove the
  1544.                loading of CLOCK.SYS.
  1545.  
  1546.                You  will still need to run CLK as part of every boot operation
  1547.                (e.g.,  in AUTOEXEC.BAT) to do any automatic adjustment (A= and
  1548.                L=  functions),  check  for  clock  failures (W= function), and
  1549.                check  to see whether the clock should use the standard or day-
  1550.                light   offsets  (TZ=  function).    These  functions  are  not
  1551.                processed  automatically  by  CLOCK.SYS  because they would in-
  1552.                crease the size of the device driver to an unacceptable limit.
  1553.  
  1554.           /?
  1555.                "/?"  or  any error will cause CLK to display the usage format.
  1556.                If  you  have  an  error  in any field, CLK first displays that
  1557.                field.
  1558.  
  1559.           TZ=:?
  1560.                "TZ=:?"  or  any  error in a TZ= function that refers to a pre-
  1561.                defined  time  zone  causes CLK to display all the current pre-
  1562.                defined time zone names and their associated values.
  1563.  
  1564. 3.2  Using CLK with Windows
  1565.  
  1566. If you use the TZ= function and also use WINDOWS, you will need to modify your
  1567. SYSTEM.INI  file.    The  SYSTEM.INI  file is found in your WINDOWS directory.
  1568. WINDOWS performs a function very similar to the C=R function, but WINDOWS uses
  1569. the  BIOS  to  go directly to the hardware clock and hence bypasses CLOCK.SYS.
  1570. The result will usually be your time changing everytime you enter WINDOWS.  
  1571.  
  1572. Fortunately  you  can  avoid  that  by  editing  the  SYSTEM.INI file.  In the
  1573. SYSTEM.INI file, find the line that looks like:
  1574.  
  1575. [386Enh]
  1576.  
  1577. Immediately after that line or anywhere in the [386Enh] section, insert a line
  1578. that looks like:
  1579.  
  1580. SyncTime=false
  1581.  
  1582. 3.3  Calculating the Adjustment Factor
  1583.  
  1584. The  M=  function  will help you determine the value of A=.  The most powerful
  1585. form  is  M=LAST.  Whenever you set the time or date, CLOCK.SYS saves the time
  1586. that  is  currently  stored in the calendar clock and the new time.  Then when
  1587. you use M=LAST, CLK reads those two values and calculates what the M= function
  1588. should look like for you.  This is especially powerful in that you can use any
  1589. clock  setting  program including those that dial the Naval observatory, NIST,
  1590. or other source.  Then immediately follow that operation with CLK M=LAST.
  1591.  
  1592. Of  course,  M=LAST  is  equally valuable if you are adjusting the clock using
  1593. your  watch  and  the TIME command of DOS.  Just follow up with CLK M=LAST and
  1594. the information will be captured.
  1595.  
  1596.  
  1597.                                       24
  1598.  
  1599.  
  1600.  
  1601.  
  1602.           CLOCK Version 3.70                              November 20, 1994
  1603.  
  1604.  
  1605. The  PC  clocks  can  never be arbitrarily accurate and the best you can do is
  1606. usually about 5 seconds per month of accuracy.  Some PCs will be less accurate
  1607. at  best and others will be more accurate.  The drift rate in the clock is not
  1608. quite a constant and the adjustment factor really only operates to the nearest
  1609. 18th of a second.
  1610.  
  1611. For  this  reason, you are better off waiting to set a new time and use the M=
  1612. function  until  your  clock is at least a few seconds off.  The more accurate
  1613. your  current adjustment, the longer you will wait between manual changes.  Of
  1614. course,  that's  exactly  what  automatic adjustment is about anyway.  Waiting
  1615. until  an adjustment of several seconds is required keeps the calculation from
  1616. oscillating  due  to  the inherent errors in the calculation being of the same
  1617. order of magnitude as the adjustment change.
  1618.  
  1619. Once you are satisfied that the new adjustment calculated by your M= functions
  1620. is  correct,  the easiest way to apply it is to use A=M on a CLK command.  A=M
  1621. tells  CLK  to  use  the  current  calculated  adjustment  using your previous
  1622. adjustment and all the M= values as the new adjustment value.  It has the same
  1623. effect  as  if  you  had typed A=xxxx where xxxx was the calculated adjustment
  1624. displayed previously.
  1625.  
  1626. Example
  1627.  
  1628. Set time (Use your watch or favorite program)
  1629. CLK M=LAST
  1630. Wait a few days or weeks
  1631. Set time
  1632. CLK M=LAST
  1633. Wait a few days or weeks
  1634. Set time
  1635. CLK M=LAST
  1636. Wait a few days or weeks
  1637. Set time
  1638. CLK M=LAST (keep repeating until the calculation stabilizes)
  1639. CLK A=M
  1640.  
  1641. 3.4  Format of TZ= Function
  1642.  
  1643. The  format  of  TZ=... can get quite complicated as the standard is trying to
  1644. deal  with  all  time  zones and daylight savings time rules around the world.
  1645. The full format is:
  1646.  
  1647.      TZ=:zone
  1648.      or
  1649.      TZ=STD[offset][DAY[offset][,start[/time],end[/time]]]
  1650.  
  1651. Parameters     zone
  1652.                The  form TZ=:zone is the one you are most likely to need.  CLK
  1653.                knows  the  offsets and daylight savings time rules for most of
  1654.                the  U.S.  and  all you have to supply is the name of your time
  1655.                zone.  The time zones currently known to CLK are:
  1656.                EST  Eastern U.S. with automatic daylight
  1657.                CST  Central U.S. with automatic daylight
  1658.                MST  Mountain U.S. with automatic daylight
  1659.                PST  Pacific U.S. with automatic daylight
  1660.  
  1661.                                       25
  1662.  
  1663.  
  1664.  
  1665.  
  1666.           CLOCK Version 3.70                              November 20, 1994
  1667.  
  1668.  
  1669.                HST  Hawaiian with no daylight savings time
  1670.                MET  Mediterranean with automatic daylight
  1671.  
  1672.                You  can  use CLK TZ=:? to display the list of pre-defined zone
  1673.                names and their values.
  1674.  
  1675.                If  you would like your favorite time added, please send me the
  1676.                names,  offset  from  UTC,  and any daylight savings time rules
  1677.                that  are  different  from  the  U.S.   NOTE:  The names can be
  1678.                composed  of  any  characters  except  digits, plus, minus, and
  1679.                comma.    They  can  be  up  to  32  characters  long.  Case is
  1680.                preserved  in the names only for later display by CLK.  You can
  1681.                call your zone MyZone.
  1682.  
  1683.                Case  is  not important in matching the zone names.  tz=:cst is
  1684.                the  equivalent  of  TZ=:CST.  Both will find the definition of
  1685.                CST.
  1686.                         
  1687.           You  don't  have  to  wait for me to modify CLK in order to use your
  1688.           local rules or just try something out.  That's what the long form is
  1689.           for.
  1690.  
  1691.           STD
  1692.                is  any  time zone name for standard time that you want to use.
  1693.                See the note above for the rules.
  1694.  
  1695.  
  1696.           offset
  1697.                is  the  difference  between  your  local  time  and UTC and is
  1698.                expressed  as  hh[:mm[:ss]]  with  an  optional leading + or -.
  1699.                Offsets for times West of Greenwich are positive and those East
  1700.                are  negative.  A 24-hour clock is used with times running from
  1701.                00:00:00  to  23:59:59.    Mountain  Standard time would be ex-
  1702.                pressed as:
  1703.                     TZ=MST+07:00:00
  1704.                          or
  1705.                     TZ=MST7
  1706.                and  that's what you would use if you live in Arizona and don't
  1707.                want any daylight savings time adjustments.
  1708.  
  1709.           DAY
  1710.                is  the time zone name for daylight savings time.  If you don't
  1711.                use  daylight  savings  time  in  your location, you should not
  1712.                supply this or any of the following fields.
  1713.  
  1714.                The  offset  for  daylight  time  is  in  the  same form as for
  1715.                standard time.  If you don't give this offset, it is assumed to
  1716.                be  one  hour  later  than standard time.  Thus a more complete
  1717.                specification of the Eastern time zone would be:
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.                                       26
  1726.  
  1727.  
  1728.  
  1729.  
  1730.           CLOCK Version 3.70                              November 20, 1994
  1731.  
  1732.  
  1733.                     TZ=EST+05:00:00EDT+04:00:00
  1734.                          or
  1735.                     TZ=EST5EDT4
  1736.                          or
  1737.                     TZ=EST5EDT     (since  daylight  is  one hour later by de-
  1738.                                    fault)
  1739.  
  1740.           start
  1741.                is  the  day of the year on which daylight savings time starts.
  1742.                There  are  three  formats  that  you can use to give this day.
  1743.                They are given below.
  1744.  
  1745.           end
  1746.                is  the  day  of  the year on which standard time starts again.
  1747.                Note  that  in the Southern hemisphere it is quite possible for
  1748.                "end"  to  be  earlier  in  the  year  than "start" as daylight
  1749.                savings  time will include December and January.  end is in the
  1750.                same format as start.  Note from the syntax above that you must
  1751.                provide end if you provide start.
  1752.  
  1753.           time
  1754.                is  the  time  of  day  that  the change takes place.  It is in
  1755.                exactly  the  same format as offset except that leading + and -
  1756.                signs  are  not  allowed.    If  you  do  not specify the time,
  1757.                02:00:00 is used as the default.
  1758.  
  1759. The day of the year form for start and end may be any of:
  1760.  
  1761.           Jn
  1762.                where  n  is a Julian day of the year from 1 to 365.  This form
  1763.                does  not  allow you to refer to February 29.  Day 59 is always
  1764.                February  28 and Day 60 is always March 1.  This is most useful
  1765.                in  locations  where  a  particular calendar date is used every
  1766.                year.
  1767.  
  1768.           n
  1769.                where  n  is a Julian day of the year from 0 to 365.  This form
  1770.                does  allow  you  to refer to February 29.  January 1 is day 0,
  1771.                February 28 is day 58, and either February 29 or March 1 is day
  1772.                59 depending on whether it is a leap year or not.  Not the most
  1773.                useful  of  forms  but  it  does deal with locations that might
  1774.                specify February 29 as the date that time changes.
  1775.  
  1776.           Mm.w.d
  1777.                is used in places like the U.S. that do not specify a date, but
  1778.                rather specify a rule.  m is the month (1 to 12).  d is the day
  1779.                of  the  week  (0=Sunday,  1=Monday, ... 6=Saturday).  w is the
  1780.                week  of  the  month (1 to 5).  Week 1 indicates the first time
  1781.                that  day  d  occurs  in that month.  Week 5 indicates the last
  1782.                time  that  day d occurs in that month whether it is the 4th or
  1783.                5th time.  Thus the U.S. rule is
  1784.                     M4.1.0/02:00:00,M10.5.0/02:00:00
  1785.                or  the  first  Sunday in April at 2AM until the last Sunday in
  1786.                October at 2AM.
  1787.  
  1788.  
  1789.                                       27
  1790.  
  1791.  
  1792.  
  1793.  
  1794.           CLOCK Version 3.70                              November 20, 1994
  1795.  
  1796.  
  1797. The long form for Central U.S. time is:
  1798.  
  1799.      TZ=CST+06:00:00CDT+05:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00
  1800.                or
  1801.      TZ=CST6CDT5,M4.1.0/2,M10.5.0/2     (just leaving out zeros)
  1802.                or
  1803.      TZ=CST6CDT,M4.1.0,M10.5.0          (since 2AM is default)
  1804.                or
  1805.      TZ=CST6CDT                         (since the U.S. rule is the default)
  1806.  
  1807.  
  1808. 3.5  Using CLK
  1809.  
  1810. The  most  common  use  of  CLK  will be to handle your time zone and daylight
  1811. savings time changes.  You need only do the following:
  1812.  
  1813. 1.   Set your clocks to UTC.
  1814.  
  1815. 2.   Include the following line in your AUTOEXEC.BAT file.
  1816.           CLK TZ=:zone   (where you use one of the pre-defined zones)
  1817.                or
  1818.           CLK TZ=...     (where you define your own rules)
  1819.  
  1820. That's it.  Everything else will take care of itself.  
  1821.  
  1822. The  only  other time you will need to do anything is if you decide to correct
  1823. your calendar clock to a more accurate time.  You will probably use TIMESET or
  1824. one  of  the  other  programs that call the Naval Observatory or NIST or maybe
  1825. just your watch that you have set accurately.
  1826.  
  1827. If  you  don't  want  to  have to change the configuration of the time setting
  1828. program,  you  may  want  to  have  it  always  set UTC or at least your local
  1829. standard time.  If you want to have it set UTC time, do the following:
  1830.  
  1831.      CLK S=C C=W
  1832.      run your time set program
  1833.      CLK M=LAST     (to calculate the adjustment change needed)
  1834.      CLK TZ=...     (your normal TZ value)
  1835.  
  1836. The C=W in the first line is only required if you normally run with the clocks
  1837. disconnected.
  1838.  
  1839. Note that if you tell the time set program what your current time zone is, you
  1840. don't need the S=C or TZ= unless you have the clocks disconnected.
  1841.  
  1842. Notes     Leaving your clock on local time
  1843.           If  you  don't  want to be bothered with UTC, CLK will quite happily
  1844.           work  with  your  calendar  clock  set  to  its  current value.  For
  1845.           example,  let's  assume  that  you currently have both clocks set to
  1846.           Pacific  Standard  Time  and  you  don't  really want to be bothered
  1847.           changing  to UTC, but you would like future changes between standard
  1848.           and  daylight  time  to  be  handled  automatically.    Just use the
  1849.           following statement in AUTOEXEC.BAT:
  1850.                CLK TZ=PST0PDT
  1851.  
  1852.  
  1853.                                       28
  1854.  
  1855.  
  1856.  
  1857.  
  1858.           CLOCK Version 3.70                              November 20, 1994
  1859.  
  1860.  
  1861.           CLK  believes  whatever  you  tell it and will quite happily operate
  1862.           assuming that PST is equal to UTC.  You could even use CLK with your
  1863.           calendar clock set to Pacific Daylight Time by using:
  1864.                CLK TZ=PST1PDT
  1865.  
  1866.           Avoiding missed days when your PC stays on all night,
  1867.           and missed years and leap days on type 4 and 6 clocks
  1868.           If  your  PC  is  often  left on over midnight and seems to miss the
  1869.           change to a new day, use:
  1870.                CLK C=R TZ=...
  1871.           in  your  AUTOEXEC.BAT  file to have CLOCK.SYS periodically read the
  1872.           time and date from the calendar clock.  If your clock is a type 4 or
  1873.           6  clock  that doesn't update years automatically and doesn't handle
  1874.           leap  days,  then  this setting also ensures that leaving your PC on
  1875.           over  the  end  of a year or across February 29 doesn't cause you to
  1876.           get the wrong date.
  1877.  
  1878.           Using CLK.INI to simplify your commands
  1879.           If  you  always  use  the  same  functions, you may want to edit the
  1880.           CLK.INI file that is included in this release.  You can include your
  1881.           TZ=, C=, and R= functions in the file and just use:
  1882.                CLK /I
  1883.           in your AUTOEXEC.BAT file.
  1884.  
  1885.           Adding and subtracting time
  1886.           You  can pretty much do anything including simple arithmetic on your
  1887.           clocks  by  using  the functions in the correct sequence.  Let's say
  1888.           that  you  want  to  add 12 hours to the current time in both clocks
  1889.           because  you  inadvertently  set  AM  time  instead of PM time.  The
  1890.           following function sequence will do that:
  1891.                CLK TZ=Igoofed-12 S=D TZ=:pst
  1892.  
  1893.           The TZ=Igoofed-12 (or use any other name for the zone) sets your DOS
  1894.           clock  to 12 hours later than the calendar clock.  (Yes, I know that
  1895.           time  zone  offsets  seem backwards since you subtract them from the
  1896.           base time, but that's the way the official standards have them.)
  1897.  
  1898.           The  S=D  sets both clocks to the value in the DOS clock with a zero
  1899.           offset.
  1900.  
  1901.           The  TZ=:pst  should be replaced by whatever your normal TZ function
  1902.           is or even by a /I to pull in your normal settings.
  1903.  
  1904.           If you normally have your clocks disconnected, insert a C=W function
  1905.           as the first function.
  1906.  
  1907.           Correcting inadvertent problems
  1908.           Just  remember  that  except for the S=D function, CLK and CLOCK.SYS
  1909.           always start with the assumption that the calendar clock is the base
  1910.           and  do  all  their calculations from that point.  Thus you can play
  1911.           with  TZ and other functions as much as you want and always get back
  1912.           to your normal local time just by using your normal TZ command.  The
  1913.           calendar  clock will not have been affected unless you did something
  1914.           to  set  the  time  or  date.    You  can avoid even that problem by
  1915.           disconnecting  your  clocks (C=D) or restricting time changes (R=A).
  1916.  
  1917.                                       29
  1918.  
  1919.  
  1920.  
  1921.  
  1922.           CLOCK Version 3.70                              November 20, 1994
  1923.  
  1924.  
  1925.           In  fact,  if  you  have  trouble  with some program messing up your
  1926.           clocks, try the following:
  1927.  
  1928.                CLK C=D
  1929.                execute program
  1930.                CLK S=C C=W (or C=R) TZ=...  (your normal)
  1931.  
  1932.           If  you  have  your standard C= and TZ= functions in a file, you can
  1933.           simplify this as:
  1934.  
  1935.                CLK C=D
  1936.                execute program
  1937.                CLK S=C /I
  1938.  
  1939.           You may even want to make up batch files containing this sequence to
  1940.           run  those  troublesome  programs.    Some games are major causes of
  1941.           problems  because  they  set  the DOS clock running faster or slower
  1942.           than  normal  to  control  the  pace  of  the game.  As long as they
  1943.           restore  the  normal  rate  when  they exit, the above sequence will
  1944.           eliminate any clock drift problems.
  1945.  
  1946.           Fast DOS clock drift
  1947.           Some high-speed communication programs will also cause the DOS clock
  1948.           to   run  slow  by  causing  the  BIOS  to  miss  clock  interrupts.
  1949.           Fortunately,  a  C=R function should virtually eliminate problems of
  1950.           this type.
  1951.  
  1952.  
  1953. 3.6  Examples
  1954.  
  1955.      clk A=0.34
  1956.           sets  an  adjustment  factor  of  0.34  seconds per day.  The A=0.34
  1957.           function  will  be  written  to  the  CLK.INI  file along with an L=
  1958.           function  with  the  current  time  and a zero remaining adjustment.
  1959.           Every  time  thereafter, that CLK is run with the /I option, it will
  1960.           check  to see if it is time to adjust the clocks.  About every third
  1961.           day, it will add 1 second to both clocks.
  1962.  
  1963.      clk s=c /i
  1964.           sets  the  DOS  clock to the current calendar clock time without any
  1965.           time  zone  adjustment.   The /i causes all functions in the CLK.INI
  1966.           file to be added.  If one of them is a tz function, we have correct-
  1967.           ed  the  DOS clock for any changes made to it and re-established our
  1968.           time zone.  This is a good command line to use following a 
  1969.                clk c=d
  1970.           and  other  operations that may have led to an incorrect time in the
  1971.           DOS clock.
  1972.  
  1973.      clk c=r tz=:est r=b-00:00:02 r=f+00:00:02
  1974.           sets CLOCK.SYS to read the calendar clock about every 10 seconds and
  1975.           re-synchronize  the  DOS  clock  with  it;  applies  the appropriate
  1976.           Eastern  time  zone  (standard  or  daylight depending on date); and
  1977.           prohibits  changes  to  the  clock  of more than 2 seconds in either
  1978.           direction.
  1979.  
  1980.  
  1981.                                       30
  1982.  
  1983.  
  1984.  
  1985.  
  1986.           CLOCK Version 3.70                              November 20, 1994
  1987.  
  1988.  
  1989.  
  1990. 3.7  Errors
  1991.  
  1992. When  errors  are detected, CLK prints a message.  It also sets the ERRORLEVEL
  1993. on each program termination as follows:
  1994.  
  1995. 0    Normal termination or only warning messages.
  1996.  
  1997. 1    Time outside warning range.  Warning issued.
  1998.  
  1999. 2    Error  in  command line or CLK.INI file functions.  The function with the
  2000.      error is displayed followed by the appropriate usage rules.
  2001.  
  2002. 3    Internal   error  or  system  error  (e.g.,  unable  to  open  handle  to
  2003.      CLOCK.SYS).
  2004.  
  2005.  
  2006. 3.8  Future Enhancements
  2007.  
  2008. Several enhancements are planned for future releases of CLK.
  2009.  
  2010.      -    Full  screen  interface  that displays the current status of all the
  2011.           things  that CLK and CLOCK.SYS know and lets you change them just by
  2012.           editing  the screen.  The rather clunky command line interface needs
  2013.           to remain as its compact function definitions are what you want in a
  2014.           .BAT file.
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.                                       31
  2046.  
  2047.  
  2048.  
  2049.  
  2050.           CLOCK Version 3.70                              November 20, 1994
  2051.  
  2052.  
  2053. 4.  CLKDEMO.EXE
  2054.  
  2055. A  simple  version  of  the  CLK  program, called CLKDEMO, is provided in both
  2056. executable  and  source  code  form.  CLKDEMO only provides support for the C=
  2057. functions  and displaying the clock status.  It is included to show you how to
  2058. add  clock  handling to your own applications.  CLKDEMO is written in C and is
  2059. compiled  with  Microsoft Visual C++ but can be compiled with earlier versions
  2060. like version 5.1.
  2061.  
  2062.  
  2063. 4.1  CLKDEMO Command Line
  2064.  
  2065. Syntax    CLKDEMO [C=A|D|R|W] [/?]
  2066.  
  2067. The  functions provided work exactly as they do in CLK.  CLKDEMO also displays
  2068. the status and the current times.
  2069.  
  2070. Since CLKDEMO.EXE is merely a subset of CLK.EXE, it isn't terribly useful as a
  2071. utility  in  its  own  right.   Its value is that the source code is provided.
  2072. There are three source code files provided.  CLKDEMO.C is the main program and
  2073. performs  command interpretation and execution.  IOCTL.C is a set of functions
  2074. that  read  and  write the CLOCK$ device driver using the DOS IOCTL functions.
  2075. IOCTL.H  is  a  set  of  definitions  which  are  used by CLKDEMO and IOCTL.C.
  2076. CLKTYP.H  is  a list of the clock types currently supported by these programs.
  2077. It is used to display the type.
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.                                       32
  2110.  
  2111.  
  2112.  
  2113.  
  2114.           CLOCK Version 3.70                              November 20, 1994
  2115.  
  2116.  
  2117. 5.  IOCTL - API TO CLOCK.SYS
  2118.  
  2119. IOCTL  is  provided  to  allow  you  to build your own applications to use the
  2120. additional  functions  that  CLOCK.SYS  provides.    There  are  several  APIs
  2121. (Application  Programming  Interfaces) provided as part of IOCTL.  These  APIs
  2122. are sufficient to perform all of the extended functions.
  2123.  
  2124. All  of  the  APIs  are  defined  to  be  directly callable from all Microsoft
  2125. compatible  languages  including  MASM, FORTRAN, Pascal, and BASIC.  Languages
  2126. other  than  C  refer  to the API names as upper case characters.  Object code
  2127. versions  are  provided for the small, medium, and large memory models.  These
  2128. may  be  linked directly with your applications.  The object code versions are
  2129. SIOCTL.OBJ, MIOCTL.OBJ, and LIOCTL.OBJ for the small, medium, and large models
  2130. respectively.
  2131.  
  2132.  
  2133. 5.1  Data Structures
  2134.  
  2135. Data structures are defined in ioctl.h that are used in the calls to the IOCTL
  2136. functions.
  2137.  
  2138.  
  2139. /* "modes" holds flags that control the operation of CLOCK.SYS */
  2140.  
  2141. struct modes {
  2142.     unsigned : 9;
  2143.     unsigned day_light: 1;
  2144.     unsigned disp_24 : 1;
  2145.     unsigned disp_tim : 1;
  2146.     unsigned pw_ena : 1;
  2147.     unsigned disabl : 1;
  2148.     unsigned chk_forw : 1;
  2149.     unsigned chk_back : 1;
  2150. };
  2151.  
  2152. /* "off" holds a time offset in hours, minutes, and seconds. */
  2153.  
  2154. struct off {
  2155.     int hour;
  2156.     int minute;
  2157.     int second;
  2158. };
  2159.  
  2160. /* "date_time" is a structure that holds a date and time.    */
  2161.  
  2162. struct date_time {
  2163.     int year;
  2164.     int month;
  2165.     int day;
  2166.     struct off time;
  2167.     int hsecond;
  2168. };
  2169.  
  2170.  
  2171.  
  2172.  
  2173.                                       33
  2174.  
  2175.  
  2176.  
  2177.  
  2178.           CLOCK Version 3.70                              November 20, 1994
  2179.  
  2180.  
  2181. /* "time_zone" holds a time zone name and offset.   */
  2182.  
  2183. struct time_zone {
  2184.     struct off offs;
  2185.     unsigned char zone[32];
  2186. };
  2187.  
  2188. /* "limit" is used to hold the data that sets time limits for changes.    */
  2189.  
  2190. struct limit {
  2191.     struct off back;
  2192.     struct off forward;
  2193. };
  2194. /*  "disp" is used to hold the data that specifies the location and attributes
  2195. of the continuous time display.   */
  2196.  
  2197. struct disp {
  2198.     int x;
  2199.     int y;
  2200.     int attribute;
  2201. };
  2202.  
  2203. /* CLOCK_DATA is the CLOCK.SYS data that is returned by clksta (AKA CLKSTA for
  2204. FORTRAN,  Pascal,  and  BASIC  languages).    Because  we  need to be language
  2205. independent,  all  of  the  data is word-aligned.  Only the data types int and
  2206. character are used.  Some of the int data is encoded bits or addresses.  */
  2207.  
  2208. struct CLOCK_DATA {
  2209.     int connected;               /* Connection state          */
  2210.     struct modes mode;           /* Mode bits                 */
  2211.     struct date_time cal_time;   /* Current date and time     */
  2212.     struct time_zone standard;   /* Offset of standard UTC    */
  2213.     struct time_zone daylight;   /* Daylight offset           */
  2214.     struct limit rules;          /* Maximum clock movement    */
  2215.     struct disp display;         /* Time display loc and attr */
  2216.     unsigned char vers[6];       /* CLOCK.SYS version nnn.nn  */
  2217.     int clock_type;              /* Type of clock installed   */
  2218.     int ct_1;                    /* Data for clock type       */
  2219.     int ct_2;
  2220.     int ct_3;
  2221.     int ct_4;
  2222.     unsigned int clock_seg;      /* Segment CLOCK.SYS loaded at*/
  2223.     unsigned int clock_long;     /* Size of CLOCK.SYS          */
  2224.     struct date_time prev_time;  /* Time just before change    */
  2225.     struct date_time new_time;   /* Time just set              */
  2226. };
  2227.  
  2228. This  data  structure is treated as the following integer array in the FORTRAN
  2229. and BASIC languages.
  2230.  
  2231. BASIC
  2232.      OPTION BASE 1
  2233.      DIM CDATA(80)
  2234.  
  2235.  
  2236.  
  2237.                                       34
  2238.  
  2239.  
  2240.  
  2241.  
  2242.           CLOCK Version 3.70                              November 20, 1994
  2243.  
  2244.  
  2245. FORTRAN
  2246.      INTEGER*2 CDATA(80)
  2247.  
  2248. ARRAY INDEX         CONTENTS                 STRUCTURE ELEMENT
  2249.  
  2250. CDATA(1)       =    Connection state         connected
  2251. CDATA(2)       =    Mode bits                mode
  2252. CDATA(3)       =    Year from calendar clock cal_time.year
  2253. CDATA(4)       =    Month                    cal_time.month
  2254. CDATA(5)       =    Day                      cal_time.day
  2255. CDATA(6)       =    Hour                     cal_time.offs.hour
  2256. CDATA(7)       =    Minute                   cal_time.offs.minute
  2257. CDATA(8)       =    Second                   cal_time.offs.second
  2258. CDATA(9)       =    100th of second          cal_time.hsecond
  2259. CDATA(10)      =    Standard hours from UTC  standard.offs.hour
  2260. CDATA(11)      =    Standard minutes         standard.offs.minute
  2261. CDATA(12)      =    Standard seconds         standard.offs.second
  2262. CDATA(13) -                                  standard.zone
  2263. CDATA(28)      =    Standard time zone LJSF
  2264. CDATA(29)      =    Daylight hours from UTC  daylight.offs.hour
  2265. CDATA(30)      =    Daylight minutes         daylight.offs.minute
  2266. CDATA(31)      =    Daylight seconds         daylight.offs.second
  2267. CDATA(32) -                                  daylight.zone
  2268. CDATA(47)      =    Daylight time zone LJSF
  2269. CDATA(48)      =    Maximum hours backward   rules.back.hour
  2270. CDATA(49)      =    Maximum minutes backward rules.back.minute
  2271. CDATA(50)      =    Maximum seconds backward rules.back.second
  2272. CDATA(51)      =    Maximum hours forward    rules.forward.hour
  2273. CDATA(52)      =    Maximum minutes forward  rules.forward.minute
  2274. CDATA(53)      =    Maximum seconds forward  rules.forward.second
  2275. CDATA(54)      =    x cursor position        display.x
  2276. CDATA(55)      =    y cursor position        display.y
  2277. CDATA(56)      =    attribute                display.attribute
  2278. CDATA(57) -                                  vers
  2279. CDATA(59)      =    CLOCK.SYS version LJSF
  2280. CDATA(60)      =    Clock type               clock_type
  2281. CDATA(61)      =    I/O address, base memory ct_1
  2282.                     segment, or base year
  2283. CDATA(62)      =    Read memory offset       ct_2
  2284. CDATA(63)      =    Write-0 memory offset    ct_3
  2285. CDATA(64)      =    Write-1 memory offset    ct_4
  2286. CDATA(65)      =    Segment address          clock_seg
  2287.                     where CLOCK.SYS is loaded
  2288. CDATA(66)      =    Length of CLOCK.SYS      clock_long
  2289. CDATA(67)      =    Year from previous       prev_time.year
  2290. CDATA(68)      =    Month                    prev_time.month
  2291. CDATA(69)      =    Day                      prev_time.day
  2292. CDATA(70)      =    Hour                     prev_time.offs.hour
  2293. CDATA(71)      =    Minute              prev_time.offs.minute
  2294. CDATA(72)      =    Second              prev_time.offs.second
  2295. CDATA(73)      =    100th of second          prev_time.hsecond
  2296. CDATA(74)      =    Year from new time       new_time.year
  2297. CDATA(75)      =    Month                    new_time.month
  2298. CDATA(76)      =    Day                      new_time.day
  2299. CDATA(77)      =    Hour                     new_time.offs.hour
  2300.  
  2301.                                       35
  2302.  
  2303.  
  2304.  
  2305.  
  2306.           CLOCK Version 3.70                              November 20, 1994
  2307.  
  2308.  
  2309. CDATA(78)      =    Minute                   new_time.offs.minute
  2310. CDATA(79)      =    Second                   new_time.offs.second
  2311. CDATA(80)      =    100th of second          new_time.hsecond
  2312.  
  2313.  
  2314. 5.2  clksta
  2315.  
  2316. ■  Summary
  2317.  
  2318. C
  2319.  
  2320. #include <ioctl.h>
  2321.  
  2322. extern int pascal far clksta(struct CLOCK_DATA *cdata);
  2323.  
  2324. BASIC
  2325.  
  2326. OPTION BASE 1
  2327. DIM CDATA(80)
  2328.  
  2329. DECLARE FUNCTION CLKSTA%(BYVAL Addr AS INTEGER)
  2330.  
  2331. STATUS% = CLKSTA(VARPTR(CDATA(1)))
  2332.  
  2333. FORTRAN
  2334.  
  2335. INTEGER*2 CDATA(80)
  2336. INTEGER*2 STATUS
  2337. INTEGER*2 CLKSTA
  2338.  
  2339. STATUS = CLKSTA(CDATA)
  2340.  
  2341. ■  Description
  2342.  
  2343. clksta  returns  all  of  the  information about CLOCK.SYS in a structure.  In
  2344. FORTRAN  and  BASIC  the  structure appears to be an integer array.  The above
  2345. structure  declarations  can  be approximated in Pascal.  For a description of
  2346. the  values  of each element, see the individual APIs below.  The elements not
  2347. described as part of the input to other functions are:
  2348.  
  2349. unsigned char vers[6];      /* CLOCK.SYS version nnn.nn     */
  2350. int clock_type;             /* Type of clock installed      */
  2351. int ct_1;                   /* Data for clock type          */
  2352. int ct_2;
  2353. int ct_3;
  2354. int ct_4;
  2355. unsigned int clock_seg;     /* Segment CLOCK.SYS loaded at  */
  2356. unsigned int clock_long;    /* Size of CLOCK.SYS            */
  2357.  
  2358. CDATA(57) -
  2359. CDATA(59)      =    CLOCK.SYS version LJSF characters
  2360. CDATA(60)      =    Clock type (see type numbers in appendix B)
  2361. CDATA(61)      =    I/O address, base memory segment, or base year
  2362. CDATA(62)      =    Read memory offset
  2363. CDATA(63)      =    Write-0 memory offset
  2364.  
  2365.                                       36
  2366.  
  2367.  
  2368.  
  2369.  
  2370.           CLOCK Version 3.70                              November 20, 1994
  2371.  
  2372.  
  2373. CDATA(64)      =    Write-1 memory offset
  2374. CDATA(65)      =    Segment address at which CLOCK.SYS is loaded
  2375. CDATA(66)      =    Length in bytes of CLOCK.SYS
  2376.  
  2377.      vers or CDATA(57) - CDATA(59)
  2378.           Is  the  version number of the CLOCK.SYS that is installed.  This is
  2379.           returned  as  a  6-character,  left-justified,  space-filled  (LJSF)
  2380.           character string.  For example, "3.49  ".
  2381.  
  2382.      clock_type or CDATA(60)
  2383.           Is  the type number of the clock being used.  See Appendix B for the
  2384.           type numbers.
  2385.  
  2386.      ct_1 or CDATA(61)
  2387.           Is  the  value  of  the first clock parameter.  This is the base I/O
  2388.           address  for  I/O  bus  clocks,  the base memory segment address for
  2389.           memory-mapped clocks, or the base year for the AT&T clocks.
  2390.  
  2391.      ct_2 or CDATA(62)
  2392.           Is the read offset for memory-mapped clocks.
  2393.  
  2394.      ct_3 or CDATA(63)
  2395.           Is the write 0-bits offset for memory-mapped clocks.
  2396.  
  2397.      ct_4 or CDATA(64)
  2398.           Is the write 1-bits offset for memory-mapped clocks.
  2399.  
  2400.      clock_seg or CDATA(65)
  2401.           Is  the  segment  address  at  which CLOCK.SYS is loaded.  CLOCK.SYS
  2402.           always starts at offset zero in this segment.
  2403.  
  2404.      clock_long or CDATA(66)
  2405.           Is the length of CLOCK.SYS in bytes.
  2406.  
  2407. ■ Arguments         cdata
  2408.                          is a pointer to a location to place the current state
  2409.                          information from CLOCK.SYS.
  2410.  
  2411. ■  Return Value
  2412.  
  2413. If clksta is successful, the function returns 0.  Otherwise, it returns a non-
  2414. zero  value  and  _doserrno  is set to the corresponding error code.  Possible
  2415. values are:
  2416.  
  2417.      0001h     Invalid  function.   This should indicate that CLOCK.SYS is not
  2418.                installed.    It  is the error that the DOS clock device driver
  2419.                would return since it doesn't handle these functions.
  2420.  
  2421.      0005h     Access  denied.  Indicates that DOS would not open a handle for
  2422.                read access.  You may not have enough handles available.
  2423.  
  2424.      0006h     Invalid handle.  Should not happen.
  2425.  
  2426.      000Dh     Invalid data.  CLOCK.SYS reported a bad byte count or otherwise
  2427.                did not process the request.  This should not happen.
  2428.  
  2429.                                       37
  2430.  
  2431.  
  2432.  
  2433.  
  2434.           CLOCK Version 3.70                              November 20, 1994
  2435.  
  2436.  
  2437.  
  2438. 5.3  setpw
  2439.  
  2440. ■ Summary
  2441.  
  2442. C
  2443.  
  2444. #include <ioctl.h>
  2445.  
  2446. extern void pascal far setpw(unsigned char *pw);
  2447.  
  2448. BASIC
  2449.  
  2450. DECLARE SUB SETPW(BYVAL S AS INTEGER)
  2451.  
  2452. A$ = "MyPasswd"
  2453. CALL SETPW(SADD(A$))
  2454.  
  2455. Note  that A$ must be at least 8 characters long.  Only the first 8 characters
  2456. will be used.
  2457.  
  2458. FORTRAN
  2459.  
  2460. CHARACTER*8 PW
  2461.  
  2462. PW = "MyPasswd"
  2463. CALL SETPW(PW)
  2464.  
  2465. ■  Description
  2466.  
  2467. The  setpw function sets the password to be used on subsequent calls to any of
  2468. the following functions.  These functions automatically supply the most recent
  2469. password  when  they  call CLOCK.SYS.  You need not ever call setpw if you are
  2470. not  using  password  protection.    CLOCK.SYS will only check the password if
  2471. password protection is enabled through the stmode function.
  2472.  
  2473. ■ Arguments         pw
  2474.                          is  a  pointer  to  the password string.  This string
  2475.                          should  be  exactly  8 characters long and must be at
  2476.                          least 8 characters long.  The password should also be
  2477.                          LJSF  as  every  character  is  significant.  Case is
  2478.                          significant in passwords.
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.                                       38
  2494.  
  2495.  
  2496.  
  2497.  
  2498.           CLOCK Version 3.70                              November 20, 1994
  2499.  
  2500.  
  2501. ■  Example
  2502.  
  2503. #include <ioctl.h>
  2504.  
  2505. main()
  2506.  
  2507. {
  2508.         unsigned char pw[9] = "MyPasswd";
  2509.  
  2510. /* Set password to use on subsequent function calls.  */
  2511.  
  2512.         setpw(pw);
  2513.  
  2514. }
  2515.  
  2516.  
  2517. 5.4  connec
  2518.  
  2519. ■  Summary
  2520.  
  2521. C
  2522.  
  2523. #include <ioctl.h>
  2524.  
  2525. extern int pascal far connec(int *conn);
  2526.  
  2527. BASIC
  2528.  
  2529. DECLARE FUNCTION CONNEC%(CONN AS INTEGER)
  2530.  
  2531. STATUS% = CONNEC(CONN)
  2532.  
  2533. FORTRAN
  2534.  
  2535. INTEGER*2 CONN, STATUS, CONNEC
  2536.  
  2537. STATUS = CONNEC(CONN)
  2538.  
  2539. ■  Description
  2540.  
  2541. The  connec  function  provides  a  means  of  setting the connection state of
  2542. CLOCK.SYS.
  2543.  
  2544. ■  Arguments   conn
  2545.                     specifies the new connection mode.  The values are:
  2546.                     0 = disconnected (C=D)
  2547.                     1 = connected for writes only (C=W)
  2548.                     2 = connected for writes and periodic reads (C=R)
  2549.                     3 = connected for all operations (C=A)
  2550.  
  2551.  
  2552. ■ Return Value
  2553.  
  2554. If  the  return value is zero, the function succeeded.  If the return value is
  2555. non-zero,  an  error  has  occurred  and _doserrno is set to the corresponding
  2556.  
  2557.                                       39
  2558.  
  2559.  
  2560.  
  2561.  
  2562.           CLOCK Version 3.70                              November 20, 1994
  2563.  
  2564.  
  2565. error code.  Possible values are:
  2566.  
  2567.      0001h     Invalid  function.   This should indicate that CLOCK.SYS is not
  2568.                installed.    It  is the error that the DOS clock device driver
  2569.                would return since it doesn't handle these functions.
  2570.  
  2571.      0005h     Access  denied.  Indicates that DOS would not open a handle for
  2572.                read access.  You may not have enough handles available.
  2573.  
  2574.      0006h     Invalid handle.  Should not happen.
  2575.  
  2576.      000Dh     Invalid data.  CLOCK.SYS reported a bad byte count or otherwise
  2577.                did not process the request.  This should not happen.
  2578.  
  2579. ■  Example
  2580.  
  2581. #include <stdio.h>
  2582. #include <ioctl.h>
  2583.  
  2584. main()
  2585. {
  2586.      int conn_write = 1;
  2587.      int status;
  2588.  
  2589. /* Set clock to connected for writes */
  2590.  
  2591.      status = connec(&conn_write);
  2592.      if (status)
  2593.           printf("Error %X in connec\n", status);
  2594. }
  2595.  
  2596.  
  2597. 5.5  newpw
  2598.  
  2599. ■  Summary
  2600.  
  2601. C
  2602.  
  2603. #include <ioctl.h>
  2604.  
  2605. extern int pascal far newpw(unsigned char *pw);
  2606.  
  2607. BASIC
  2608.  
  2609. DECLARE FUNCTION NEWPW%(BYVAL S AS INTEGER)
  2610.  
  2611. A$ = "MyPasswd"
  2612. STATUS% = NEWPW(SADD(A$))
  2613.  
  2614. Note  that A$ must be at least 8 characters long.  Only the first 8 characters
  2615. will be used.
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.                                       40
  2622.  
  2623.  
  2624.  
  2625.  
  2626.           CLOCK Version 3.70                              November 20, 1994
  2627.  
  2628.  
  2629. FORTRAN
  2630.  
  2631. CHARACTER*8 PW
  2632. INTEGER*2 STATUS, NEWPW
  2633.  
  2634. PW = "MyPasswd"
  2635. STATUS = NEWPW(PW)
  2636.  
  2637. ■  Description
  2638.  
  2639. The  newpw  function  sets a new password for CLOCK.SYS.  This function is not
  2640. sufficient to enable password protection.  You must also use stmode to turn on
  2641. password  checking.    BE  SURE  to use newpw before you use stmode to turn on
  2642. password checking.  If you turn on password checking without first setting the
  2643. password  to  something  that  you  know,  you  will  never be able to use the
  2644. CLOCK.SYS functions again until you reboot.
  2645.  
  2646. ■ Arguments         pw
  2647.                          is  a  pointer  to  the password string.  This string
  2648.                          should  be  exactly  8 characters long and must be at
  2649.                          least 8 characters long.  The password should also be
  2650.                          LJSF  as  every  character  is  significant.  Case is
  2651.                          significant in passwords.
  2652.  
  2653. ■ Return Value
  2654.  
  2655. If  the  return value is zero, the function succeeded.  If the return value is
  2656. non-zero,  an  error  has  occurred  and _doserrno is set to the corresponding
  2657. error code.  Possible values are:
  2658.  
  2659.      0001h     Invalid  function.   This should indicate that CLOCK.SYS is not
  2660.                installed.    It  is the error that the DOS clock device driver
  2661.                would return since it doesn't handle these functions.
  2662.  
  2663.      0005h     Access  denied.  Indicates that DOS would not open a handle for
  2664.                read access.  You may not have enough handles available.
  2665.  
  2666.      0006h     Invalid handle.  Should not happen.
  2667.  
  2668.      000Dh     Invalid data.  CLOCK.SYS reported a bad byte count or otherwise
  2669.                did not process the request.  This should not happen.
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.                                       41
  2686.  
  2687.  
  2688.  
  2689.  
  2690.           CLOCK Version 3.70                              November 20, 1994
  2691.  
  2692.  
  2693. ■  Example
  2694.  
  2695. #include <stdio.h>
  2696. #include <ioctl.h>
  2697.  
  2698. main()
  2699.  
  2700. {
  2701.         unsigned char pw[9] = "MyPasswd";
  2702.        int status;
  2703.  
  2704. /* Set new password for CLOCK.SYS  */
  2705.  
  2706.         status = setpw(pw);
  2707.        if (status)
  2708.           printf("Error %X in setpw\n", status);
  2709.  
  2710. }
  2711.  
  2712.  
  2713. 5.6  rstrct
  2714.  
  2715. ■  Summary
  2716.  
  2717. C
  2718.  
  2719. #include <ioctl.h>
  2720.  
  2721. extern int pascal far rstrct(int *bhour, int *bmin, int *bsec,
  2722.     int *fhour, int *fmin, int *fsec);
  2723.  
  2724. BASIC
  2725.  
  2726. DECLARE FUNCTION RSTRCT%(BHOUR%, BMIN%, BSEC%, FHOUR%, FMIN%, FSEC%)
  2727.  
  2728. FORTRAN
  2729.  
  2730. INTEGER*2 BHOUR, BMIN, BSEC, FHOUR, FMIN, FSEC
  2731. INTEGER*2 RSTRCT
  2732.  
  2733. STATUS = RSTRCT(BHOUR, BMIN, BSEC, FHOUR, FMIN, FSEC)
  2734.  
  2735. ■  Description
  2736.  
  2737. The  rstrct  function sets backwards and forwards limits on time changes.  Any
  2738. time  changes  that  exceed  these  limits will be ignored.  For example, if a
  2739. backward  limit  of  2  seconds  is  set,  no change that would move the clock
  2740. backwards  more than 2 seconds will be processed.  Setting the limits protects
  2741. you  agains  keying in a bad time and agains programs that may incorrectly set
  2742. the  time.    Yet  you can still change the time within the prescribed limits.
  2743. For example, you may set a backward limit of 2 seconds to permit CLK to adjust
  2744. the  time  by  up  to  2 seconds while inhibiting any other backwards changes.
  2745. These limits have no effect on changing between standard and daylight times as
  2746. that is not really a change in the "time".
  2747.  
  2748.  
  2749.                                       42
  2750.  
  2751.  
  2752.  
  2753.  
  2754.           CLOCK Version 3.70                              November 20, 1994
  2755.  
  2756.  
  2757. ■ Arguments         bhour:bmin:bsec
  2758.                          is the backward limit in hours, minutes and seconds.
  2759.  
  2760.                     fhour:fmin:fsec
  2761.                          is the forward limit in hours, minutes, and seconds.
  2762.  
  2763. ■ Return Value
  2764.  
  2765. If  the  return value is zero, the function succeeded.  If the return value is
  2766. non-zero,  an  error  has  occurred  and _doserrno is set to the corresponding
  2767. error code.  Possible values are:
  2768.  
  2769.      0001h     Invalid  function.   This should indicate that CLOCK.SYS is not
  2770.                installed.    It  is the error that the DOS clock device driver
  2771.                would return since it doesn't handle these functions.
  2772.  
  2773.      0005h     Access  denied.  Indicates that DOS would not open a handle for
  2774.                read access.  You may not have enough handles available.
  2775.  
  2776.      0006h     Invalid handle.  Should not happen.
  2777.  
  2778.      000Dh     Invalid data.  CLOCK.SYS reported a bad byte count or otherwise
  2779.                did not process the request.  This should not happen.
  2780.  
  2781.  
  2782. ■  Example
  2783.  
  2784. #include <stdio.h>
  2785. #include <ioctl.h>
  2786.  
  2787. main()
  2788.  
  2789. {
  2790.      int bhour = 0;
  2791.      int bmin = 0;
  2792.      int bsec = 2;
  2793.      int fhour = 1;
  2794.      int fmin = 0;
  2795.      int fsec = 0;
  2796.      int status;
  2797.  
  2798. /* Set time change limits to 2 seconds backwards and 1 hour forwards  */
  2799.  
  2800.      status = rstrct(&bhour, &bmin, &bsec, &fhour, &fmin, &fsec);
  2801.      if (status)
  2802.           printf("Error %X in rstrct\n", status);
  2803.      else
  2804.           printf("Time limits set to "
  2805.                "-%.2d:%.2d:%.2d,+%.2d:%.2d:%.2d\n",
  2806.                bhour, bmin, bsec, fhour, fmin, fsec);
  2807. }
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.                                       43
  2814.  
  2815.  
  2816.  
  2817.  
  2818.           CLOCK Version 3.70                              November 20, 1994
  2819.  
  2820.  
  2821. 5.7  stmode
  2822.  
  2823. ■  Summary
  2824.  
  2825. C
  2826.  
  2827. #include <ioctl.h>
  2828.  
  2829. extern int pascal far stmode(struct modes *mode);
  2830.  
  2831. BASIC
  2832.  
  2833. DECLARE FUNCTION STMODE%(MODES%)
  2834.  
  2835. FORTRAN
  2836.  
  2837. INTEGER*2 MODES
  2838. INTEGER*2 STMODE
  2839.  
  2840. STATUS = STMODE(MODES)
  2841.  
  2842. ■  Description
  2843.  
  2844. The  stmode  function  sets  a  variety  of  operating modes.  The argument is
  2845. actually a structure of bits.  Each bit specifies whether an operating mode is
  2846. on (1) or off (0).
  2847.  
  2848. ■ Arguments         modes
  2849.                          is set of bits that specify operating modes.  The bit
  2850.                          values are:
  2851.  
  2852.                          unsigned : 9;            Unused
  2853.                          unsigned day_light: 1;        
  2854.                                                   0x0200 (512)
  2855.                          unsigned disp_24 : 1;    0x0400 (1024)
  2856.                          unsigned disp_tim : 1;   0x0800 (2048)
  2857.                          unsigned pw_ena : 1;     0x1000 (4096)
  2858.                          unsigned disabl : 1;     0x2000 (8192)
  2859.                          unsigned chk_forw : 1;   0x4000 (16384)
  2860.                          unsigned chk_back : 1;   0x8000 (32768)
  2861.  
  2862. ■ Return Value
  2863.  
  2864. If  the  return value is zero, the function succeeded.  If the return value is
  2865. non-zero,  an  error  has  occurred  and _doserrno is set to the corresponding
  2866. error code.  Possible values are:
  2867.  
  2868.      0001h     Invalid  function.   This should indicate that CLOCK.SYS is not
  2869.                installed.    It  is the error that the DOS clock device driver
  2870.                would return since it doesn't handle these functions.
  2871.  
  2872.      0005h     Access  denied.  Indicates that DOS would not open a handle for
  2873.                read access.  You may not have enough handles available.
  2874.  
  2875.      0006h     Invalid handle.  Should not happen.
  2876.  
  2877.  
  2878.                                       44
  2879.  
  2880.  
  2881.  
  2882.  
  2883.           CLOCK Version 3.70                              November 20, 1994
  2884.  
  2885.  
  2886.      000Dh     Invalid data.  CLOCK.SYS reported a bad byte count or otherwise
  2887.                did not process the request.  This should not happen.
  2888.  
  2889.  
  2890. ■  Example
  2891.  
  2892. #include <ioctl.h>
  2893.  
  2894. main()
  2895.  
  2896. {
  2897.      struct CLOCK_DATA cdata;
  2898.  
  2899. /* Set daylight savings time.  */
  2900.  
  2901.      clksta(&cdata);            /* Get current mode settings. */
  2902.  
  2903.      cdata.mode.day_light = 1;  /* Turn on daylight */
  2904.  
  2905.      stmode(&cdata.modes);
  2906. }
  2907.  
  2908.  
  2909. 5.8  stzone
  2910.  
  2911. ■  Summary
  2912.  
  2913. C
  2914.  
  2915. #include <ioctl.h>
  2916.  
  2917. extern int pascal far stzone(int *shour, int *smin, int *ssec,
  2918.     unsigned char sname[32], int *dhour, int *dmin,
  2919.     int *dsec, unsigned char dname[32]);
  2920.  
  2921.  
  2922. BASIC
  2923.  
  2924. DECLARE  FUNCTION  STZONE%(SHOUR%,  SMIN%, SSEC%, BYVAL SN AS INTEGER, DHOUR%,
  2925. DMIN%, DSEC%, BYVAL DN AS INTEGER)
  2926.  
  2927. SNAME$ = "32-CHARACTER STANDARD ZONE NAME "
  2928. DNAME$ = "Daylight savings time zone name "
  2929.  
  2930. STATUS% = STZONE(6,0,0,SADD(SNAME$),5,0,0,SADD(DNAME$))
  2931.  
  2932. FORTRAN
  2933.  
  2934. CHARACTER*32 SNAME, DNAME
  2935. INTEGER*2 STZONE, STATUS
  2936.  
  2937. SNAME = "CST"
  2938. DNAME = "CDT"
  2939. STATUS = STZONE(6, 0, 0, SNAME, 5, 0, 0, DNAME)
  2940.  
  2941.  
  2942.                                       45
  2943.  
  2944.  
  2945.  
  2946.  
  2947.           CLOCK Version 3.70                              November 20, 1994
  2948.  
  2949.  
  2950. ■  Description
  2951.  
  2952. The  stzone  function sets the standard time and daylight savings time offsets
  2953. from  the  calendar  clock  and  the  standard and daylight time zone names or
  2954. mnemonics.    Note  that the offsets are subtracted from the calendar clock to
  2955. get the local time.  Thus the standard time offset from UTC to EST is 5:0:0.
  2956.  
  2957. ■ Arguments         SHOUR:SMIN:SSEC
  2958.                          is the time difference between the calendar clock and
  2959.                          local  standard  time.    It  may  be  a  positive of
  2960.                          negative  value.   If negative, all three values must
  2961.                          be negative.
  2962.  
  2963.                     SNAME
  2964.                          is  the standard time zone name or mnemonic.  It must
  2965.                          be a 32-character LJSF character string.  As with all
  2966.                          other  character  strings  used  by  these functions,
  2967.                          there is no terminating NULL character as is usual in
  2968.                          C.    The  other languages do not readily handle NULL
  2969.                          terminated strings.  In C applications you may define
  2970.                          the character array to contain 33 characters, but you
  2971.                          must ensure that the NULL character does not occur in
  2972.                          the first 32 characters.
  2973.  
  2974.                     DHOUR:DMIN:DSEC
  2975.                          is the time difference between the calendar clock and
  2976.                          local  daylight  savings  time.  Whether the standard
  2977.                          offset  or  the  daylight offset is currently used by
  2978.                          CLOCK.SYS   is  controlled  by  the  setting  of  the
  2979.                          day_light mode bit (see stmode).
  2980.  
  2981.                     DNAME
  2982.                          is  the  daylight savings time zone name or mnemonic.
  2983.                          It must be a 32-character LJSF character string.
  2984.  
  2985. ■ Return Value
  2986.  
  2987. If  the  return value is zero, the function succeeded.  If the return value is
  2988. non-zero,  an  error  has  occurred  and _doserrno is set to the corresponding
  2989. error code.  Possible values are:
  2990.  
  2991.      0001h     Invalid  function.   This should indicate that CLOCK.SYS is not
  2992.                installed.    It  is the error that the DOS clock device driver
  2993.                would return since it doesn't handle these functions.
  2994.  
  2995.      0005h     Access  denied.  Indicates that DOS would not open a handle for
  2996.                read access.  You may not have enough handles available.
  2997.  
  2998.      0006h     Invalid handle.  Should not happen.
  2999.  
  3000.      000Dh     Invalid data.  CLOCK.SYS reported a bad byte count or otherwise
  3001.                did not process the request.  This should not happen.
  3002.  
  3003.  
  3004.  
  3005.  
  3006.                                       46
  3007.  
  3008.  
  3009.  
  3010.  
  3011.           CLOCK Version 3.70                              November 20, 1994
  3012.  
  3013.  
  3014. ■  Example
  3015.  
  3016. #include <stdio.h>
  3017. #include <ioctl.h>
  3018.  
  3019. main()
  3020.  
  3021. {
  3022.      unsigned char sname[33] = "PST                    ";
  3023.      unsigned char dname[33] = "PDT                    ";
  3024.      int shour = 8;
  3025.      int smin = 0;
  3026.      int ssec = 0;
  3027.      int dhour = 7;
  3028.      int dmin = 0;
  3029.      int dsec = 0;
  3030.      struct CLOCK_DATA cdata;
  3031.  
  3032. /* Get current status.   */
  3033.  
  3034.      clksta(&cdata);
  3035.  
  3036. /* Set time zone to U.S. Pacific time.  */
  3037.  
  3038.      stzone(&shour, &smin, &ssec, sname, &dhour, &dmin, &dsec,
  3039.          dname);
  3040.  
  3041. /* Select daylight savings time.  */
  3042.  
  3043.      cdata.mode.day_light = 1;
  3044.      stmode(&cdata.mode);
  3045. }
  3046.  
  3047.  
  3048. 5.9  tdisp
  3049.  
  3050. ■  Summary
  3051.  
  3052. C
  3053.  
  3054. #include <ioctl.h>
  3055.  
  3056. extern int pascal far tdisp(int *dispx, int *dispy, int *attr);
  3057.  
  3058. BASIC
  3059.  
  3060. DECLARE FUNCTION TDISP%(DISPX%, DISPY%, ATTR%)
  3061.  
  3062. STATUS% = TDISP(72, 0, &H79)
  3063.  
  3064. FORTRAN
  3065.  
  3066. INTEGER*2 TDISP, STATUS
  3067.  
  3068. STATUS = TDISP(0, 72, 0x79)
  3069.  
  3070.                                       47
  3071.  
  3072.  
  3073.  
  3074.  
  3075.           CLOCK Version 3.70                              November 20, 1994
  3076.  
  3077.  
  3078. ■  Description
  3079.  
  3080. The  tdisp function sets the coordinates and attribute for the continuous time
  3081. display.   tdisp does not start or stop the continuous display nor does it set
  3082. the 12-hour or 24-hour mode.  Those are all provided by the stmode function.
  3083.  
  3084. ■ Arguments         DISPX
  3085.                          is  the  x  (horizontal)  cursor  coordinate  for the
  3086.                          continuous  time display.  The rightmost character on
  3087.                          a  line  is at x=0.  Be sure to leave enough space at
  3088.                          the end of the line to accommodate the entire 8-char-
  3089.                          aracter  time display.  For example, x=72 is the last
  3090.                          position to specify on an 80-character line.
  3091.  
  3092.                     DISPY
  3093.                          is   the  y  (vertical)  cursor  coordinate  for  the
  3094.                          continuous time display.  The top line on the display
  3095.                          is y=0.
  3096.  
  3097.                     ATTR
  3098.                          is  the  display  attribute to use for the continuous
  3099.                          time  display.   ATTR is usually expressed as two hex
  3100.                          digits.    The  first (high-order) digit is the back-
  3101.                          ground  color  (0  to  7) and the second digit is the
  3102.                          text  or  foreground color (0 to F).  For example, 0A
  3103.                          would  display  bright green letters on a black back-
  3104.                          ground.  Background colors usually do not include the
  3105.                          bright colors.  The color numbers are:
  3106.  
  3107.                               0    Black
  3108.                               1    Blue
  3109.                               2    Green
  3110.                               3    Cyan
  3111.                               4    Red
  3112.                               5    Magenta
  3113.                               6    Brown
  3114.                               7    White
  3115.                               8    Grey
  3116.                               9    Bright blue
  3117.                               A    Bright green
  3118.                               B    Brigth cyan
  3119.                               C    Bright red
  3120.                               D    Bright magenta
  3121.                               E    Yellow
  3122.                               F    Bright White
  3123.  
  3124. ■ Return Value
  3125.  
  3126. If  the  return value is zero, the function succeeded.  If the return value is
  3127. non-zero,  an  error  has  occurred  and _doserrno is set to the corresponding
  3128. error code.  Possible values are:
  3129.  
  3130.      0001h     Invalid  function.   This should indicate that CLOCK.SYS is not
  3131.                installed.    It  is the error that the DOS clock device driver
  3132.                would return since it doesn't handle these functions.
  3133.  
  3134.                                       48
  3135.  
  3136.  
  3137.  
  3138.  
  3139.           CLOCK Version 3.70                              November 20, 1994
  3140.  
  3141.  
  3142.      0005h     Access  denied.  Indicates that DOS would not open a handle for
  3143.                read access.  You may not have enough handles available.
  3144.  
  3145.      0006h     Invalid handle.  Should not happen.
  3146.  
  3147.      000Dh     Invalid data.  CLOCK.SYS reported a bad byte count or otherwise
  3148.                did not process the request.  This should not happen.
  3149.  
  3150.  
  3151. ■  Example
  3152.  
  3153. #include <stdio.h>
  3154. #include <ioctl.h>
  3155.  
  3156. main()
  3157.  
  3158. {
  3159.      struct CLOCK_DATA cdata;
  3160.      int dispx = 72;
  3161.      int dispy = 0;
  3162.      int attr = 0x79;
  3163.  
  3164. /* Get current CLOCK.SYS modes.  */
  3165.  
  3166.      clksta(&cdata);
  3167.  
  3168. /* Turn on 12-hour display at end of top line of screen. 
  3169.    Use bright blue text on a white backgroun.          */
  3170.  
  3171.      tdisp(&dispx, &dispy, &attr);
  3172.      cdata.mode.disp_tim = 1;
  3173.      cdata.mode.disp_24 = 0;
  3174.      stmode(&cdata.mode);
  3175.      
  3176. }
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.                                       49
  3199.  
  3200.  
  3201.  
  3202.  
  3203.           CLOCK Version 3.70                              November 20, 1994
  3204.  
  3205.  
  3206. 6.  CLOCK.SYS - ASSEMBLY LANGUAGE API
  3207.  
  3208. CLOCK.SYS has a couple of additional APIs (Application Programming Interfaces)
  3209. that are not present in the normal DOS CLOCK$ device driver.  These interfaces
  3210. are  provided  by the DOS IOCTL (Input/Output of ConTroL data) functions.  The
  3211. Output  Control Data to Character Device function is used to set new operating
  3212. values  for  CLOCK.SYS  for  the C=, D=, R=, TZ=, and /P functions.  The Input
  3213. Control  Data from Character Device function is used to get the current status
  3214. and the date and time from the calendar clock.
  3215.  
  3216.  
  3217. 6.1  Opening the CLOCK$ Device
  3218.  
  3219. In  order  to  use  the  additional APIs provided by CLOCK.SYS you must open a
  3220. handle  to  the  CLOCK$ device driver.  You do this using the DOS INT 21H Open
  3221. File  with  Handle  (3DH) function specifying read-write access.  You then use
  3222. the handle to invoke the other functions.  Sample assembly language is:
  3223.      MOV  AX,3D00H            ; Open with read and write access
  3224.      MOV  DX,OFFSET filename  ; Pointer to "CLOCK$" ASCIIZ string
  3225.                               ; DS:DX must point to the string
  3226.      INT  21H                 ; Call DOS function handler
  3227. ;    AX contains the handle on return if carry flag is not set.
  3228.  
  3229.  
  3230. 6.2  Sending New Values to CLOCK.SYS
  3231.  
  3232. To  change  the state of CLOCK.SYS, you use the Send Control Data to Character
  3233. Device  (4403H)  DOS  function.  You send data to specify the connection type,
  3234. m o des,  time  zone  offsets  and  names,  restrictions,  continuous  display
  3235. information,  and  password.    You  may  send any combination of these in any
  3236. order.    You  must always send the current password as the first 8 bytes.  If
  3237. password  checking is not enabled, it doesn't matter what the 8 bytes contain,
  3238. but you must still send the 8 bytes.
  3239.  
  3240. The  data  stream  that you send to CLOCK.SYS consists of the current password
  3241. followed  by a selection index, the data for that selection, another selection
  3242. index, its data, and so on.
  3243.  
  3244. The selection indices and the data stream associated with each one are:
  3245.  
  3246. INDEX     DATA ITEMS     COMMENTS
  3247.  
  3248. 1         connected      two byte integer (0 : C=D, 1 : C=W, 2 : C=R, 3 : C=A)
  3249.  
  3250. 2         mode           two byte integer (see stmode for a description of the
  3251.                          bits)
  3252.  
  3253. 3         standard       time_zone structure for standard time
  3254.           daylight       time_zone structure for daylight time
  3255.  
  3256. 4         rules          limits structure
  3257.  
  3258. 5         display        disp structure
  3259.  
  3260. 6         password       8 bytes LJSF of new password
  3261.  
  3262.                                       50
  3263.  
  3264.  
  3265.  
  3266.  
  3267.           CLOCK Version 3.70                              November 20, 1994
  3268.  
  3269.  
  3270. Sample assembly language to send new information to CLOCK.SYS:
  3271.  
  3272. curpw     DB   8 dup(?)       ; Current password
  3273.           DW   1              ; Change connection
  3274.                
  3275.           DW   2              ;  to C=R
  3276.           DW   4              ; Change limits
  3277.           DW   0,0,2,1,0,0    ;  to R=B-::2,F+1
  3278.           DW   6              ; Set new password
  3279.           DB   "MyPasswd"     ;  to MyPasswd (case is important)
  3280.           DW   2              ; Change modes
  3281.           DW   0D000H         ;  to enable limits and password
  3282.                               ;  also sets standard time and 
  3283.                               ;  no display
  3284. count     equ $-curpw              
  3285.                               ; Length to send
  3286.      ...
  3287.           MOV  AX,4403H       ; Send control data function
  3288.           MOV  BX,handle      ; Value returned from open
  3289.           MOV  CX,count       ; Value = number of bytes to send
  3290.           MOV  DX,OFFSET curpw ; Location of bytes to be sent
  3291.                               ; DS:DX must point to the buffer
  3292.           INT  21H            ;
  3293. ; OK if carry not set.  CX will equal bytes actually taken.
  3294.  
  3295.  
  3296. 6.3  Getting Current Status of CLOCK.SYS
  3297.  
  3298. To  get  the  current  status  and time, you use the Receive Control Data from
  3299. Character  Device  (4402H)  function.    You  can  read  all of the CLOCK_DATA
  3300. structure  or  any  smaller  amount of it that you need, but you can only read
  3301. starting at the beginning
  3302.  
  3303. Sample assembly language for reading the clock status is:
  3304.  
  3305.      MOV  AX,440CH            ; Read control data function
  3306.      MOV  BX,handle           ; Value returned from open
  3307.           
  3308.      MOV  CX,count            ; Number of bytes to read
  3309.      MOV  DX,OFFSET buffer    ; Location to store the data
  3310.                               ; DS:DX must point to the buffer
  3311.      INT  21H                      
  3312.                               ; Call DOS
  3313. ; Data returned if carry not set.
  3314. ; CX will contain the actual number of bytes transferred.
  3315.  
  3316.  
  3317.  
  3318.  
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.                                       51
  3331.  
  3332.  
  3333.  
  3334.  
  3335.           CLOCK Version 3.70                              November 20, 1994
  3336.  
  3337.  
  3338. APPENDIX A:  DEFINITION OF SHAREWARE
  3339.  
  3340. Shareware  distribution gives users a chance to try software before buying it.
  3341. If  you  try  a  Shareware  program and continue using it, you are expected to
  3342. register.  Individual  programs differ on details -- some request registration
  3343. while  others require it, some specify a maximum trial period.  With registra-
  3344. tion, you get anything from the simple right to continue using the software to
  3345. an updated program with printed manual.
  3346.  
  3347. Copyright  laws  apply  to  both  Shareware  and  commercial software, and the
  3348. copyright  holder retains all rights, with a few specific exceptions as stated
  3349. below.  Shareware  authors  are accomplished programmers, just like commercial
  3350. authors, and the programs are of comparable quality. (In both cases, there are
  3351. good programs and bad ones!) The main difference is in the method of distribu-
  3352. tion.  The  author  specifically  grants  the right to copy and distribute the
  3353. software,  either  to all and sundry or to a specific group. For example, some
  3354. authors  require  written  permission before a commercial disk vendor may copy
  3355. their Shareware.
  3356.  
  3357. Shareware  is  a  distribution method, not a type of software. You should find
  3358. software  that  suits  your  needs  and pocketbook, whether it's commercial or
  3359. Shareware.  The  Shareware system makes fitting your needs easier, because you
  3360. can  try before you buy. And because the overhead is low, prices are low also.
  3361. Shareware  has  the  ultimate  money-back  guarantee  --  if you don't use the
  3362. product, you don't pay for it.
  3363.  
  3364. DISCLAIMER - AGREEMENT
  3365.  
  3366. Users of CLOCK must accept this disclaimer of warranty:  "CLOCK is supplied as
  3367. is.    The  author  disclaims all warranties, expressed or implied, including,
  3368. without  limitation,  the warranties of merchantability and of fitness for any
  3369. purpose.    The  author assumes no liability for damages, direct or consequen-
  3370. tial, which may result from the use of CLOCK."
  3371.  
  3372. CLOCK  is  a  "shareware program" and is provided at no charge to the user for
  3373. evaluation.    Feel free to share it with your friends, but please do not give
  3374. it away altered or as part of another system.  The essence of "user-supported"
  3375. software  is  to provide personal computer users with quality software without
  3376. high  prices,  and  yet  to  provide  incentive for programmers to continue to
  3377. develop  new  products.  If you find this program useful and find that you are
  3378. using  CLOCK  and  continue  to use CLOCK after a reasonable trial period, you
  3379. must  make  a  registration payment of $10 to Ronald Q. Smith.  The $10 regis-
  3380. tration fee will license one copy for use on any one computer at any one time.
  3381. For  a registration fee of $25, I will immediately send you the latest version
  3382. of  CLOCK  including  the  source  code and this document as a WordPerfect 5.1
  3383. file.    You may use the source code for your own maintenance of CLOCK or as a
  3384. learning  tool for any software that you develop.  You may not use all or part
  3385. of  the  source  code  in  any  software that you develop or release to others
  3386. without the permission of Ronald Q. Smith.
  3387.  
  3388. You  must  treat  this  software  just  like  a book.  An example is that this
  3389. software  may be used by any number of people and may be freely moved from one
  3390. computer  location  to another, so long as there is no possibility of it being
  3391. used  at one location while it's being used at another.  Just as a book cannot
  3392. be read by two different persons at the same time.
  3393.  
  3394.                                       52
  3395.  
  3396.  
  3397.  
  3398.  
  3399.           CLOCK Version 3.70                              November 20, 1994
  3400.  
  3401.  
  3402. Commercial  users  of  CLOCK  must  register and pay for their copies of CLOCK
  3403. within  30  days  of  first  use  or their license is withdrawn.  Site-License
  3404. arrangements may be made by contacting Ronald Q. Smith.
  3405.  
  3406. Anyone  distributing  CLOCK  for  any  kind of remuneration must first contact
  3407. Ronald Q. Smith at the address below for authorization.
  3408.  
  3409. You  are  encouraged  to  pass  a  copy  of  CLOCK  along  to your friends for
  3410. evaluation.    Please  encourage them to register their copy if they find that
  3411. they  can  use  it.    All  registered users will receive a copy of the latest
  3412. version of the CLOCK system.
  3413.  
  3414. Send the fees and any inquiries to:
  3415.  
  3416.                Ronald Q. Smith
  3417.                11 Black Oak Road
  3418.                St. Paul, MN 55127-6204
  3419.  
  3420. You  may  also  contact me via CompuServe mail at userid 71620,514.  I will be
  3421. happy to respond to any problems and suggestions for future capabilities.
  3422.  
  3423. You  may register CLOCK through the CompuServe Shareware Registration program.
  3424. CLOCK.SYS is found under registration ID 104.  The fee for registering through
  3425. CompuServe  is  $12 (to cover their charge) and will be added directly to your
  3426. CompuServe bill.
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.  
  3437.  
  3438.  
  3439.  
  3440.  
  3441.  
  3442.  
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.  
  3449.  
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.                                       53
  3459.  
  3460.  
  3461.  
  3462.  
  3463.           CLOCK Version 3.70                              November 20, 1994
  3464.  
  3465.  
  3466. APPENDIX B:  CLOCK TYPES
  3467.  
  3468.  
  3469. B.1  Type 0 - PC/AT
  3470.  
  3471. IBM  PC/AT  and  all fully compatible PCs.  Most versions of DOS fully support
  3472. this clock interface without a separate driver.  Use CLOCK.SYS to provide sup-
  3473. port  for  CLK.EXE  and CLKDEMO.EXE.  If you don't need the extra functions of
  3474. CLK,  you probably don't need CLOCK.SYS.  However, there were a couple of late
  3475. 8088  PCs  that adopted the PC/AT clock standard but did not provide the PC/AT
  3476. recognition sentinel.  DOS will not find the clock, but CLOCK.SYS will.
  3477.  
  3478. Amstrad PC1521DD and NEC MultiSpeed systems use this type of clock.
  3479.                 
  3480. Automatic  determination checks location F000:FFFE for the hex value FC.  Also
  3481. checks  by  just  trying  to  read  the  time and seeing if we get the correct
  3482. answer.
  3483.  
  3484. BIOS  calls  are  used  to  read  and write the clock values which are usually
  3485. stored  in  the  CMOS  RAM  along  with  other configuration information.  The
  3486. primary interfaces are:
  3487.                 
  3488.      Get Date: MOV  AH,4
  3489.                INT  1AH
  3490.                     Returns  the  year  in  CX  and month and day in DX in BCD
  3491.                     format  (e.g., a hex display would show:  CX=1991, DX=1009
  3492.                     for October 9, 1991).
  3493.  
  3494.      Set Date: MOV  AH,5
  3495.                     Load CX and DX as above for Get Date
  3496.                INT  1AH
  3497.  
  3498.      Get Time: MOV  AH,2
  3499.                INT  1AH
  3500.                     Returns  hours  and minutes in CX and seconds in DH in BCD
  3501.                     format.    May  also return 100ths of seconds in DL (e.g.,
  3502.                     CX=2359, DX=5900 for 1 second before midnight).
  3503.  
  3504.      Set Time: MOV  AH,3
  3505.                     Load CX and DX as for Get Time
  3506.                INT  1AH
  3507.  
  3508.  
  3509.  
  3510. B.2  Type 1 - Zenith Z-18x portables, Supersport 20
  3511.  
  3512. Automatic  determination  checks location F000:FFFA for the two-byte hex value
  3513. 4D32 ("M2").
  3514.  
  3515. BIOS calls are used to read and write the clock.
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.                                       54
  3523.  
  3524.  
  3525.  
  3526.  
  3527.           CLOCK Version 3.70                              November 20, 1994
  3528.  
  3529.  
  3530.      Get Date: MOV  AH,2
  3531.                INT  1AH
  3532.                     Returns  CX=year  (1980  -  2079)  in binary and DH=month,
  3533.                     DL=day.    All  values  are  binary.  A hex display of the
  3534.                     above date would look like CX=7C7, DX=A09.
  3535.  
  3536.      Set Date: MOV  AH,3
  3537.                     Load CX and DX as for Get Date.
  3538.                INT  1AH
  3539.  
  3540.      Get Time: MOV  AH,4
  3541.                INT  1AH
  3542.                     Returns  CH=hours,  CL=minutes, DH=seconds.  A hex display
  3543.                     would show: CX=173B, DX=3B00.
  3544.  
  3545.      Set Time: MOV  AH,5
  3546.                     Load CX and DX as for Get Time.
  3547.                INT  1AH
  3548.  
  3549.  
  3550. B.3  Type 2 - Various Zenith Data System PCs.
  3551.  
  3552. A u t omatic  determination  looks  at  location  F000:800A  for  the  pattern
  3553. 00,F0,"ZDS".
  3554.  
  3555.      Get Date: MOV  AH,2AH
  3556.                INT  1AH
  3557.                     Returns CX and DX as for type 1.
  3558.  
  3559.      Set Date: MOV  AH,2BH
  3560.                     Load CX and DX as for type 1.
  3561.                INT  1AH
  3562.  
  3563.      Get Time: MOV  AH,2CH
  3564.                INT  1AH
  3565.                     Returns CX and DX as for type 1.
  3566.  
  3567.      Set Time: MOV  AH,2DH
  3568.                     Load CX and DX as for type 1.
  3569.                INT  1AH
  3570.  
  3571.  
  3572. B.4  Type 3 - Memory-Mapped Clocks
  3573.  
  3574. Memory-mapped  clock  used  on  some Zenith Data Systems PCs and other similar
  3575. clocks  including  many  slot-less  or  no-slot  clocks.    The  SMT  (Systems
  3576. Manufacturing Technology) No-Slot clocks are supported by this type.
  3577.  
  3578. Automatic determination is to attempt to read the clock.  If values other than
  3579. all 0FFH or 0 are obtained, this clock type is chosen.  All known segments and
  3580. offsets are tried.
  3581.  
  3582. Several  different  memory  mapping  approaches  are  used  and many different
  3583. address  possibilities are supported.  In general a segment address in the ROM
  3584. region  (C800H  through FFFFH) is used.  Offsets from that segment address are
  3585.  
  3586.                                       55
  3587.  
  3588.  
  3589.  
  3590.  
  3591.           CLOCK Version 3.70                              November 20, 1994
  3592.  
  3593.  
  3594. used  to  read  bits,  write zero bits, and write one bits.  Documentation may
  3595. specify  those  segments and addresses in several forms.  For example, segment
  3596. F000 with offset F002 is the same as segment FF00 with offset 2.
  3597.  
  3598. Each  memory reference reads or writes a single bit.  Read operations are used
  3599. for  all  references  with  separate offsets for reading a bit, writing a zero
  3600. bit, and writing a one bit.
  3601.  
  3602. Clock segments and addresses currently probed include:
  3603.  
  3604.     ╔═══════╤═════════╤════════╤═════╤═════╤═════╤════════╗
  3605.     ║SEGMENT│WRITE 0  │WRITE 1 │READ │DECR │LAST │VENDOR  ║
  3606.     ╟───────┼─────────┼────────┼─────┼─────┼─────┼────────╢
  3607.     ║F000   │ F002    │F003    │F004 │0000 │F000 │(Zenith)║
  3608.     ╟───────┼─────────┼────────┼─────┼─────┼─────┼────────╢
  3609.     ║FE00   │    2    │   3    │   5 │0080 │C800 │SMT     ║
  3610.     ╟───────┼─────────┼────────┼─────┼─────┼─────┼────────╢
  3611.     ║FE00   │    0    │   2    │   8 │0080 │C800 │SMT     ║
  3612.     ╚═══════╧═════════╧════════╧═════╧═════╧═════╧════════╝
  3613.  
  3614. Multiple  address  combinations may be tried for each clock pattern.  The DECR
  3615. value  is  subtracted  from  the  SEGMENT value for another attempt at probing
  3616. until  the  value  equals  LAST.  Note that like the SEGMENT address, DECR and
  3617. LAST  are in units of paragraphs (16-bytes).  Thus DECR of 80 is equivalent to
  3618. 800H or 2048 bytes.
  3619.  
  3620. When  the  addresses  used by a memory-mapped clock are determined by probing,
  3621. the  segment  and  read  address is displayed.  As the read address varies the
  3622. most  from  one  clock  manufacturer to another it is a good indication of the
  3623. type of clock found.
  3624.  
  3625. Data  is  stored  in  BCD in bytes that you construct by shifting in the bits.
  3626. The most important data bytes are: 
  3627.      0 = Hundredths of seconds
  3628.      1 = Seconds
  3629.      2 = Minutes
  3630.      3 = hours
  3631.      5 = days
  3632.      6 = months
  3633.      7 = years mod 1980
  3634.  
  3635.  
  3636. B.5  Type 4 - Direct Register I/O Bus Clock
  3637.  
  3638. Many  add-in clocks on expansion boards use this type of clock.  Some built-in
  3639. clocks  in  PCs  are also accessed similarly.  This clock was used on many AST
  3640. Research  I/O  boards  for  8088  PCs such as the Six-Pack Plus, IO Plus, etc.
  3641. Also used on some Tandy systems (e.g., 1200HD) and the Vendex Turbo-888-XT.
  3642.  
  3643. Automatic determination is to attempt to read, complement, write, re-read, and
  3644. re-complement  one  of  the  registers.    If  the  first  value  read and the
  3645. re-complemented second value are equal, the register exists and is presumed to
  3646. be the clock.
  3647.  
  3648. See  also the description for types 6 and 7.  If you aren't sure which variant
  3649.  
  3650.                                       56
  3651.  
  3652.  
  3653.  
  3654.  
  3655.           CLOCK Version 3.70                              November 20, 1994
  3656.  
  3657.  
  3658. you  have, specify type 8 and automatic probing will determine if it is really
  3659. a  type  4,  6,  or 7.  For the greatest chance of detecting the correct clock
  3660. type, supply the base I/O address if at all possible.
  3661.  
  3662. NOTE:  If the clock is not correctly initialized (e.g., you have just replaced
  3663. the  battery),  CLOCK.SYS  must  initialize it so that the counters will start
  3664. working.   CLOCK.SYS determines that the clock has been previously initialized
  3665. by  looking  at  register 14H (see B below).  If register B contains the value
  3666. 0DEH,  the  clock is presumed to be initialized.  If not, CLOCK.SYS will clear
  3667. all  the registers to zero and start the counters running.  While this form of
  3668. checking for initialization was commonly used, your previous software may have
  3669. used  a  different  method.  If so, the first time you run CLOCK.SYS your date
  3670. and  time may be set to zero (1980-1-1 00:00:00).  If that happens, just enter
  3671. the  date and time.  It should work OK after that without resetting to zero on
  3672. further boots.
  3673.  
  3674. Each  clock register is implemented as a separate I/O register address.  Clock
  3675. base  I/O  addresses  of 240H, 2C0H, 300H, and 340H are supported by automatic
  3676. probing.    Similar  clocks  at  other  base  I/O  addresses  are supported by
  3677. specifying  type  4  and  the base address. The address range used is the base
  3678. plus 0 through 1FH (e.g., 2C0H through 2DFH).
  3679.                 
  3680. Important registers are (using 2C0 as the example):
  3681.                 
  3682.      2C1  =  100ths of seconds 
  3683.      2C2  =  seconds 
  3684.      2C3  =  minutes 
  3685.      2C4  =  hours 
  3686.      2C6  =  days
  3687.      2C7  =  months
  3688.      2C9  =  month last time clock was read/set 
  3689.      2CA  =  years
  3690.      2CB  =  initialized flag (0DEH if initialized)
  3691.      2D4  =  Status
  3692.                     
  3693. All  values  are  in BCD.  That means that each register consists of two 4-bit
  3694. nybbles  (a nybble is to a nibble as a byte is to a bite - I haven't seen this
  3695. used  recently,  but  as  a  bit  of  trivia,  the first IBM 360 principles of
  3696. operation  manuals used that term and that spelling - at least in a draft copy
  3697. that  we  got  in 1965).  Each nybble contains one decimal digit of the value.
  3698. Years are mod 1980 (i.e., 0 means 1980, 99 means 2079).
  3699.  
  3700. Since  these clocks do not keep the year and do not handle leap years for you,
  3701. CLOCK.SYS  does  the  necessary  calculations to keep the year correctly main-
  3702. tained  and  to adjust the date for leap days.  The clocks do provide a couple
  3703. of  memory locations in which CLOCK.SYS maintains the year and previous month.
  3704. As  long as you boot your system before a full year has passed, CLOCK.SYS will
  3705. correctly maintain the date.
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.                                       57
  3715.  
  3716.  
  3717.  
  3718.  
  3719.           CLOCK Version 3.70                              November 20, 1994
  3720.  
  3721.  
  3722. B.6  Type 5 - Mitsubishi 8088 PCs
  3723.  
  3724. These  were sold by Sperry as the PC-1 and PC/HT, by Leading Edge as the Model
  3725. D, by Mitsubishi, and others.
  3726.  
  3727. Automatic determination checks location F000:FFB3 for the string "MITSUBISHI".
  3728. Later  Mitsubishi  PCs  which  used a different clock had the same string at a
  3729. different location.  We hope all early versions had it at this location.
  3730.  
  3731. BIOS functions are used to access the clock.
  3732.  
  3733.      Get Date: MOV  AH,4
  3734.                INT  1AH
  3735.                     Returns  CL=year  mod  1980,  DH=month,  and DL=day all in
  3736.                     binary.    Also  sets AL=0FFH if the clock is busy and the
  3737.                     request should be retried.
  3738.  
  3739.      Set Date: MOV  AH,5
  3740.                     Load CL, DX as for Get Date.
  3741.                INT  1AH
  3742.                     Returns AL=0FFH if busy.
  3743.  
  3744.      Get Time: MOV  AH,2
  3745.                INT  1AH
  3746.                     Returns  CH=hour,  CL=minute,  DH=second,  and  AL=status.
  3747.                     AL=0FFH  means busy.  AL=0 means 24-hour mode.  AL=1 means
  3748.                     AM and AL=3 means PM.
  3749.  
  3750.      Set Time: MOV  AH,3
  3751.                     Load AL, CX, DH as for Get Time.
  3752.                INT  1AH
  3753.                     Returns AL=0FFH if busy.
  3754.  
  3755. NOTE:    Some  early Mitsubishi PCs came with fixed disk controllers that were
  3756. not DOS compatible.  In addition to the clock modifications, the DOS for those
  3757. systems  also  handled  the  disk  controller variant.  If you have such a PC,
  3758. CLOCK.SYS is not sufficient to enable you to go above DOS level 3.2.  You will
  3759. also  need to replace your fixed disk controller.  I strongly suggest that you
  3760. create a boot floppy for your current DOS level before you try to install your
  3761. new  DOS level.  Then boot your new DOS from a floppy disk, do SYS C: and copy
  3762. COMMAND.COM  to  C:,  then  try a disk boot.  If the disk boot fails, boot the
  3763. floppy  you just created and do a SYS C: and copy COMMAND.COM to C: to restore
  3764. your  old  DOS version.  At that point, your best bet is to simply give up and
  3765. stay  with  DOS  3.2. If you want to proceed, you must replace your fixed disk
  3766. controller.
  3767.  
  3768. If  SYS  C: gives you an error status that indicates that there isn't room for
  3769. the  new DOS version (very possible when moving from 3.2 to 3.3 or above), you
  3770. must  backup  your  entire  fixed  disk  and  use FORMAT C:/S to place the new
  3771. version of DOS on the disk.  While this is a hassle, at least if your PC won't
  3772. boot  from  the disk, the fall-back approach is identical.  There will be room
  3773. to put DOS 3.2 or earlier back on the fixed disk.
  3774.  
  3775.  
  3776.  
  3777.  
  3778.                                       58
  3779.  
  3780.  
  3781.  
  3782.  
  3783.           CLOCK Version 3.70                              November 20, 1994
  3784.  
  3785.  
  3786. B.7  Type 6 - Indirect Register I/O Bus Clock
  3787.  
  3788. Used  on  AST  Research  boards  and others.  Typically uses the same I/O base
  3789. address  as  type  4.  However the clock registers are selected by sending the
  3790. register  address  to the base I/O address and then reading or writing data at
  3791. the  base  I/O  address + 1.  The internal register numbers and their contents
  3792. are the same as for type 4.
  3793.  
  3794. Automatic determination by probing the address register.  If the low-order bit
  3795. is  one,  it  may  be  this  type of clock or type 7.  We then look further to
  3796. determine  if  it  is type 7.  If you aren't sure which type of clock you have
  3797. but  believe  it  is type 4, 6 or 7, specify type 8 and automatic probing will
  3798. detect  which  variant it is.  If at all possible specify the base I/O address
  3799. as that will increase the likelihood that the correct determination is made.
  3800.  
  3801. I/O addresses used are (again using 2C0 as the example base address):
  3802.  
  3803.      2C0    =  Address  register.  Writing a value to this address selects the
  3804.                internal register to read or write.
  3805.      2C1    =  Data  register.    Reading  or  writing  this address, reads or
  3806.                writes  the  internal  register  previously selected by writing
  3807.                2C0.
  3808.  
  3809. The internal register numbers are (the values to write to 2C0):
  3810.  
  3811.       1  =  100ths of seconds
  3812.       2  =  seconds
  3813.       3  =  minutes
  3814.       4  =  hours
  3815.       6  =  days
  3816.       7  =  months
  3817.       9  =  month last time date was read or written
  3818.       A  =  year
  3819.       B  =  initialization flag
  3820.      14  =  status
  3821.                 
  3822. Other processing is the same as type 4.
  3823.  
  3824.  
  3825. B.8  Type 7 - Complex I/O Bus Clock
  3826.  
  3827. Used  on  AST  Research  boards  and others.  Typically uses the same base I/O
  3828. address as types 4 and 6.  Type 7 uses a more complex register access sequence
  3829. than  type  6.    Type  7  can  be  detected by looking to see if the value in
  3830. register  D has bit 1 (value=2) set which type 6 will not.  If you aren't sure
  3831. which  type of clock you have but believe it is type 4, 6 or 7, specify type 8
  3832. and  automatic  probing  will  detect which variant it is.  If at all possible
  3833. specify  the  base  I/O  address as that will increase the likelihood that the
  3834. correct determination is made.
  3835.  
  3836. The base I/O address is used as an address register and the base + 1 as a data
  3837. register.    This  is  the  same  as  for clock type 6.  However, the internal
  3838. registers  and  the  form  of  the  commands  is quite different.  The primary
  3839. difference  is  that  the internal registers only hold four bits of data each.
  3840. Thus each internal register represents a single decimal digit.
  3841.  
  3842.                                       59
  3843.  
  3844.  
  3845.  
  3846.  
  3847.           CLOCK Version 3.70                              November 20, 1994
  3848.  
  3849.  
  3850. The I/O addresses are used as follows (using 2C0 as an example):
  3851.  
  3852.      2C0     = Address  register.  The number of an internal register plus 80H
  3853.                is written to this I/O address to select an internal register.
  3854.  
  3855.      2C1     = Data  register.    Four  bits of data are read or written using
  3856.                this  I/O  address  from or to the internal register previously
  3857.                selected by writing to 2C0.
  3858.  
  3859. The internal registers are:
  3860.  
  3861.      0  =  Units digit of seconds
  3862.      1  =  Tens digit of seconds
  3863.      2  =  Units digit of minutes
  3864.      3  =  Tens digit of minutes
  3865.      4  =  Units digit of hours
  3866.      5  =  Tens digit of hours
  3867.      6  =  Day of week
  3868.      7  =  Units digit of day of month
  3869.      8  =  Tens digit of day of month
  3870.      9  =  Units digit of month
  3871.      A  =  Tens digit of month
  3872.      B  =  Units digit of year
  3873.      C  =  Tens digit of year
  3874.      D  =  Function register
  3875.      E  =  Function register
  3876.      F  =  Function register
  3877.  
  3878.  
  3879. B.9  Type 8 - Generic I/O Bus Clock
  3880.  
  3881. Type  unknown.  Probe only for types 4, 6, 7, 9, and B.  Use type 8 if you are
  3882. sure that you have an I/O bus clock (i.e., the clock is on an add-in card) but
  3883. aren't  sure  whether it is type 4, 6, 7, 9, or B.  If at all possible, supply
  3884. the base I/O address of the clock as this will greatly increase the likelihood
  3885. of the correct handling method being chosen.
  3886.  
  3887.  
  3888. B.10 Type 9 - Quadram I/O Bus Clock
  3889.  
  3890. This  type  was  used by Quadram Corporation on the QuadCard, QuadCard II, and
  3891. QuadCard 512+.  It may have been used on others as well.
  3892.  
  3893. Automatic  determination  checks  to  see  that I/O registers exist at 310H or
  3894. 210H.
  3895.  
  3896. This clock used four I/O control registers and twelve internal registers.  The
  3897. I/O registers (using 310H as the example) are:
  3898.  
  3899.      310  =  Data register (used to move data values)
  3900.      311  =  Address register (used to select internal register)
  3901.      312  =  Function register (Read, write, hold counter)
  3902.      313  =  Control register (Enables read or write function)
  3903.  
  3904.  
  3905.  
  3906.                                       60
  3907.  
  3908.  
  3909.  
  3910.  
  3911.           CLOCK Version 3.70                              November 20, 1994
  3912.  
  3913.  
  3914. The internal registers are:
  3915.  
  3916.       0 = Units digit of seconds
  3917.       1 = Tens digit of seconds
  3918.       2 = Units digit of minutes
  3919.       3 = Tens digit of minutes
  3920.       4 = Units digit of hours
  3921.       5 = Tens  digit  of  hours  -  Also uses bit 2 (=4) to indicate PM if in
  3922.           12-hour mode and bit 3 (=8) to select 24-hour mode
  3923.       6 = Day of week (we don't use this)
  3924.       7 = Units digit of days
  3925.       8 = Tens digit of days - Also uses bit 3 (=8) to indicate that this is a
  3926.           leap  year.  This bit must be set by software whenever there is less
  3927.           than  366  days  until the next leap day.  If you do not boot within
  3928.           that period, leap day will not be taken.
  3929.       9 = Units digit of months
  3930.      10 = Tens digit of months
  3931.      11 = Units digit of year mod 1900 or 2000
  3932.      12 = Tens digit of year mod 1900 or 2000
  3933.  
  3934. NOTE:    If  you  have  this  type  of clock, you can only set the time to the
  3935. minute.    Whenever  the time is set, the seconds are always set to zero.  You
  3936. should set the time as the minute changes.  For that reason, you will not want
  3937. to  use  the automatic adjustment capability of CLK with this type of clock as
  3938. it will try to set the time to the nearest second.
  3939.  
  3940.  
  3941. B.11 Type A - AT&T 6300, 6300 PLUS, 6300 WGS
  3942.  
  3943. Automatic  probing  is  accomplished by trying to read the clock.  If the read
  3944. attempt  using  the  BIOS  is  successful  (carry flag not set) and the values
  3945. returned look like a valid time, the clock is assumed to be present.
  3946.  
  3947. NOTE:    AT&T clocks do not advance the year on January 1.  It is necessary to
  3948. change the date at the beginning of each year.  Also, AT&T clocks always clear
  3949. the  seconds  to  zero  when  the time is changed.  For this reason you should
  3950. always  set  the  date and time at the beginning of a minute.  You should also
  3951. not use the automatic adjustment feature of CLK with these clocks.
  3952.  
  3953. A  base year may be specified on the DEVICE= line.  If it is not, 1992 will be
  3954. used.  This base will be good for all dates from 1992-1-1 till 1999-12-31.
  3955.  
  3956. BIOS functions are used with this clock.
  3957.  
  3958.      Get Date: MOV  AH,0FEH
  3959.                INT  1AH
  3960.                     Returns BX = Days since base, CH = Hours, CL = Minutes, DH
  3961.                     = Seconds, DL = 100ths of seconds
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.                                       61
  3971.  
  3972.  
  3973.  
  3974.  
  3975.           CLOCK Version 3.70                              November 20, 1994
  3976.  
  3977.  
  3978.      Set Date: MOV  AH,0FFH
  3979.                MOV  BX,Days since base
  3980.                MOV  CH,Hours
  3981.                MOV  CL,Minutes
  3982.                MOV  DH,0
  3983.                MOV  DL,0
  3984.                INT  1AH
  3985.  
  3986.  
  3987. B.12 Type B - Hyundai 8088 Clock
  3988.  
  3989. Automatic  determination  probes the control registers.  If they, appear to be
  3990. present,  CLOCK  tries  to  read  the  clock.  Legal time and date values will
  3991. select this clock.
  3992.  
  3993. This clock uses I/O addresses E0H through EFH as follows:
  3994.      E0  =  Units digit of seconds
  3995.      E1  =  Tens digit of seconds
  3996.      E2  =  Units digit of minutes
  3997.      E3  =  Tens digit of minutes
  3998.      E4  =  Units digit of hours
  3999.      E5  =  Tens digit of hours
  4000.      E6  =  Day of week
  4001.      E7  =  Units digit of days
  4002.      E8  =  Tens digit of days
  4003.      E9  =  Units digit of month
  4004.      EA  =  Tens digit of month
  4005.      EB  =  Units digit of year
  4006.      EC  =  Tens digit of year
  4007.      ED  =  Control
  4008.      EE  =  Control
  4009.      EF  =  Control
  4010.  
  4011. B.13 Type C - Multi I/O Card Clock
  4012.  
  4013. This  clock  is  an  I/O clock that appears at address 338H in the one case we
  4014. have  found  it.  It is similar to, but not identical to, the Quadram clock in
  4015. its  operation  pattern.  The manufacturer is not known, but the clock appears
  4016. on  a  board  manufactured in Taiwan and with a label of Multi I/O Card.  This
  4017. card has a game port, floppy controller, printer, clock, etc.
  4018.  
  4019. Probing tries to read the clock and compare the values for legal ranges.
  4020.  
  4021. It  uses  three  I/O  registers.    These  are 338H, 339H, and 33AH in the one
  4022. example  found.    Register  338H is a selection and mode register used to set
  4023. read  and  write  modes  and select the internal register.  It is also read to
  4024. read  the  value  in  an internal register.  Register 339H is written to set a
  4025. value in an internal register.  Register 33AH is apparently a control register
  4026. that is used to start and stop the clock updates.
  4027.  
  4028. The internal registers are:
  4029.  
  4030.       0 = Units digit of seconds
  4031.       1 = Tens digit of seconds
  4032.       2 = Units digit of minutes
  4033.  
  4034.                                       62
  4035.  
  4036.  
  4037.  
  4038.  
  4039.           CLOCK Version 3.70                              November 20, 1994
  4040.  
  4041.  
  4042.       3 = Tens digit of minutes
  4043.       4 = Units digit of hours
  4044.       5 = Tens  digit  of  hours  -  Also uses bit 2 (=4) to indicate PM if in
  4045.           12-hour mode and bit 3 (=8) to select 24-hour mode
  4046.       6 = Day of week
  4047.       7 = Units digit of days
  4048.       8 = Tens digit of days - Also uses bit 3 (=8) to indicate that this is a
  4049.           leap  year.  This bit must be set by software whenever there is less
  4050.           than  366  days  until the next leap day.  If you do not boot within
  4051.           that period, leap day will not be taken.
  4052.       9 = Units digit of months
  4053.      10 = Tens digit of months
  4054.      11 = Units digit of year mod 1900 or 2000
  4055.      12 = Tens digit of year mod 1900 or 2000
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.                                       63
  4099.  
  4100.  
  4101.  
  4102.  
  4103.           CLOCK Version 3.70                              November 20, 1994
  4104.  
  4105.  
  4106. APPENDIX C:  REVISION HISTORY
  4107.  
  4108. 941120 -  Version  3.70:    Fix  bug  in  adjustment  calculation with M=LAST.
  4109.           Computed time difference was off by 100.
  4110.  
  4111. 940918 -  Version 3.68:  Add date display option to continuous display.
  4112.  
  4113. 940807 -  Version 3.67:  Found another incompatibility in NEC MultiSpeed.  Its
  4114.           BIOS  does  not  save  registers.   Thanks to John Seitz for help in
  4115.           finding the problems with the NEC MultiSpeed.
  4116.  
  4117. 940806 -  Version  3.66:    Adapt  type 0 to handle NEC MultiSpeed clock.  NEC
  4118.           MultiSpeed is not quite PC/AT compatible.
  4119.  
  4120. 940312 -  Version 3.65:  Fix bug in reading type 6 clock that can hang system.
  4121.  
  4122. 940208 -  Version 3.64:  Enhance type 7 clock time setting.
  4123.  
  4124. 940205 -  Version  3.63:   Fix bug when CLK M=LAST used when there has been no
  4125.           previous time set.  Fix intitialization of type 7 AST clock.
  4126.  
  4127. 931214 -  Version 3.62: Add A=M function to set adjustment to value calculated
  4128.           from M= history.
  4129.  
  4130. 931213 -  Version  3.61:  Fix bug that results in divide check in CLK if there
  4131.           are two M= values with the same date and time.
  4132.  
  4133. 931210 -  Version  3.60:  Added  M=LAST  function  to calculate the adjustment
  4134.           correction factor based on the last time the clock was set.
  4135.  
  4136. 931208 -  Version  3.58:  Finally  got  the  Hyundai  clock  to  set  the time
  4137.           correctly.   Many thanks to John Rafter for sticking with me through
  4138.           the long-distance debugging of the Hyundai support.
  4139.  
  4140. 931129 -  Version 3.57: Fixed Hyundai read to correctly handle centuries.
  4141.  
  4142. 931127 -  Version  3.56:  Change  Hyundai  write  setup  to  same  instruction
  4143.           sequence  as Hyundai.  Fix help message to remove extraneous "%s" in
  4144.           front of TZ.
  4145.  
  4146. 931123 -  Version 3.55: Change writing to Hyundai clock to do it in same order
  4147.           Hyundai did.
  4148.  
  4149. 931121 -  Version 3.54: Fix hang when using Hyundai clock.
  4150.  
  4151. 931120 -  Version  3.53:  Fix  bug  with Hyundai clock.  We left it turned off
  4152.           after reading.
  4153.  
  4154. 931119 -  Version 3.52: Fix bug when 5th day occurs on last day of month so we
  4155.           don't  change  the  time  season  too  soon.   Fix bug in displaying
  4156.           correct  clock  type  when  type  is  specified  on  DEVICE= line in
  4157.           CONFIG.SYS.  Change probing for type 4 clocks to increase likelihood
  4158.           that  we will find them even if they aren't initialized.  Fix bug in
  4159.           continuous  display  that  can cause it to display digits in reverse
  4160.           order.
  4161.  
  4162.                                       64
  4163.  
  4164.  
  4165.  
  4166.  
  4167.           CLOCK Version 3.70                              November 20, 1994
  4168.  
  4169.  
  4170. 930909 -  Version  3.51:  Allow  Quadram  clocks to be set even if seconds are
  4171.           non-zero.  Ignore seconds.
  4172.  
  4173. 930720 -  Version  3.50:  Improve documentation by explaining the two types of
  4174.           clocks in the introduction.  Also put the Windows note in a separate
  4175.           section so it is in the table of contents and easier to find.
  4176.  
  4177. 930707 -  Version 3.49: Fix writing to clock type C.
  4178.  
  4179. 930701 -  Version 3.48: Add clock type C.  Fix searching for AST clock I/O ad-
  4180.           dresses.    A  bug  crept  in at about version 3.40 that could cause
  4181.           addresses to be missed.
  4182.  
  4183. 930410 -  Version  3.47:  Add  MET time zone to list of pre-defined time zones
  4184.           (GMT-1).    Document  use of D= to resume last display.  Fix exit on
  4185.           TZ=:?.   Add documentation about modifying SYSTEM.INI when using TZ=
  4186.           in conjunction with WINDOWS.
  4187.  
  4188. 930403 -  Version  3.46:  Fix  time of switch to daylight or standard.  It was
  4189.           based on GMT and should have been based on local time.
  4190.  
  4191. 930311 -  Version 3.45: Correct M= adjustment for the pending A= adjustment.
  4192.  
  4193. 930309 -  Version  3.44: Modified M= to automatically set the date and time on
  4194.           the  L=  to  the  same as the last M= if the L= is earlier.  It also
  4195.           sets  any  remaining  adjustment to zero.  This is because the clock
  4196.           was adjusted exactly at the point represented by the M=.
  4197.  
  4198. 930306 -  Version  3.43:  Fixed bug with M= function not forcing a read of the
  4199.           A=  functions  in  CLK.INI  and  thus  not  correctly displaying the
  4200.           previous and new adjustment.
  4201.  
  4202. 930304 -  Version  3.42:  Changed time moving backwards logic to only look for
  4203.           earlier  hours.    At least one case has been seen of a program that
  4204.           set  the  time  backward a few ticks by direct calls on the BIOS and
  4205.           resulted  in  CLOCK.SYS advanceing the day.  Now we only advance the
  4206.           day  if the time moves backwards an hour or more.  Also added the /N
  4207.           option  for  CLOCK.SYS  that  shuts off this logic completely if the
  4208.           date  advances  unexpectedly.    Also  fixed  a  bug in locating the
  4209.           CLK.INI file when the A= function is used by itself.
  4210.  
  4211. 930220 -  Version 3.41: Changed timing window prevention logic in CLOCK.SYS to
  4212.           control  another  possible  case  of  the  day  advancing twice over
  4213.           midnight.
  4214.  
  4215. 930212 -  Version  3.40:  Added  the  M=  function  and  /M  option to provide
  4216.           calculation  of the adjmustment value.  Added help for all functions
  4217.           and options. Added the /B option in anticipation of later support of
  4218.           full-screen  mode.    Added  the ,C flag on the /I and /M options to
  4219.           allow  updating  a  read-only  file.    Added error messages for I/O
  4220.           errors  when  updating  the  file.  Fixed timing window in CLOCK.SYS
  4221.           that  could  occur  when  the continuous display is operational that
  4222.           could cause the date to advance unpredictably.
  4223.  
  4224. 930204 -  Version  3.31:  Fixed bug in CLOCK.SYS with some clock types causing
  4225.  
  4226.                                       65
  4227.  
  4228.  
  4229.  
  4230.  
  4231.           CLOCK Version 3.70                              November 20, 1994
  4232.  
  4233.  
  4234.           system lockups or bad data to be returned.
  4235.  
  4236. 930130 -  Version  3.30:  Added  support  for  a  password  and for saving the
  4237.           current  CLOCK.SYS  state  as  a  new  copy  of CLOCK.SYS for future
  4238.           booting.    Added  continuous  time display.  Changed API to support
  4239.           direct  calls from BASIC, FORTRAN, and Pascal as well as C and MASM.
  4240.           Changed status display to be easier to read.
  4241.  
  4242. 930115 -  Version 3.24: Converted document to WordPerfect 5.1 and rewrote much
  4243.           of  it.    Provide  document  in standard release that can either be
  4244.           viewed on-line or printed.
  4245.  
  4246. 930110 -  Version  3.23: Added support for R= and W= commands.  Fixed handling
  4247.           of CLK.INI file so that we don't try to update it if it is read only
  4248.           or  is  in a read-only sub-directory.  We also don't update it if we
  4249.           can't find the [clk] section as it may be someone else's file.
  4250.  
  4251. 930106 -  Version  3.22:  Fixed  bug  in  CLK.EXE  that  caused it to move the
  4252.           CLK.INI file to the root directory.
  4253.  
  4254. 930104 -  Version  3.21:  Fixed  bug in CLOCK.SYS expecting zero for 100ths of
  4255.           seconds  from  CMOS  clock  but  some BIOSs don't zero the register.
  4256.           Fixed  bug  in  CLK  with  synchronization  algorithm  not correctly
  4257.           waiting for a new second.
  4258.  
  4259. 930102 -  Version 3.20:  Add support for a command file, automatic adjustment,
  4260.           and improved synchronization.  My thanks to Eric Smith for the ideas
  4261.           that lead to these enhancements.
  4262.  
  4263. 921230 -  Version  3.11:    Simplified  logic  in  CLOCK.SYS  for  checking if
  4264.           calendar clock should be read.
  4265.  
  4266. 921229 -  Version 3.10: Add support for constant synchronization with calendar
  4267.           clock.  Fix bug in calculating dates near the end of leap years.
  4268.  
  4269. 921226 -  Version  3.02:  Recompile  CLK.EXE  and CLKDEMO.EXE to only use 8088
  4270.           instructions.    Version  3.01  inadvertently  compiled  with  80286
  4271.           instructions which can lock up 8088 systems.
  4272.  
  4273. 921221 -  Version  3.01: Fixed a couple of bugs in beta test version 3.00 with
  4274.           non-PC/AT  clocks.    Added  logic to CLK to display the pre-defined
  4275.           time zones on errors or request.
  4276.  
  4277. 921219 -  Version  3.00:  Added  support  for automatic time zone and daylight
  4278.           savings  time  adjustment.   CLOCK.SYS now has the ability to manage
  4279.           the  DOS real time clock and the battery-protected clock separately.
  4280.           CLK.EXE  is  used  to  convert a base value in the battery-protected
  4281.           clock to a correct local time in the DOS clock.
  4282.  
  4283. 920614 -  Version 2.24: Fixed bug in probing of AT&T 6300 clocks.  Some of the
  4284.           clocks do not set AL on successful operation.
  4285.  
  4286. 920604 -  Version  2.23:  Fixed  bug  causing fall through into memory probing
  4287.           when only I/O probing was wanted.
  4288.  
  4289.  
  4290.                                       66
  4291.  
  4292.  
  4293.  
  4294.  
  4295.           CLOCK Version 3.70                              November 20, 1994
  4296.  
  4297.  
  4298. 920411 -  Version 2.22: Changed order of probing to probe memory-mapped clocks
  4299.           last as they are being spuriously found on some Tandy systems.
  4300.  
  4301. 920401 -  Version  2.21:   Changed pattern of I/O address probing to probe all
  4302.           possible  I/O addresses for one type (e.g., 4) before trying any for
  4303.           another  type.  Try to avoid finding the wrong type.  Added the type
  4304.           B clock to the type 8 probe.
  4305.  
  4306. 920328 -  Version  2.20:  Changed order of I/O address probing for clock types
  4307.           4,  6, and 7 to avoid, where possible, accessing other boards.  Most
  4308.           commonly used I/O clock addresses, I hope, are now probed first.
  4309.  
  4310. 920322 -  Version  2.19:   Improved probing for I/O clocks to check that legal
  4311.           values  are  found  in  all  the data registers.  Several of the I/O
  4312.           clocks  use  operation  sequences so much like each other that it is
  4313.           possible  to choose the wrong one if we don't actually read the time
  4314.           and  date and see if the values are legal.  This approach to probing
  4315.           may  possibly result in not finding a clock that is present but that
  4316.           has  been  totally  reset.  Such a clock should be found on a second
  4317.           try  to  boot  with  CLOCK.SYS as the counters will have advanced by
  4318.           then.
  4319.  
  4320. 920320 -  Version 2.18:  Added probing for generic PC/AT type clock on systems
  4321.           that don't have the PC/AT signature in the BIOS.
  4322.  
  4323. 920307 -  Version 2.17:  Added Hyundai 8088 clock.
  4324.  
  4325. 920112 -  Version 2.16:  Added AT&T 6300 clock.
  4326.  
  4327. 920111 -  Version  2.15:  Fixed memory address used by one type of SMT No-Slot
  4328.           clock.
  4329.  
  4330. 920105 -  Version  2.14:    Added support for a wider variety of memory mapped
  4331.           clocks  including the SMT (Systems Manufacturing Technology) No-Slot
  4332.           clocks.
  4333.  
  4334. 911208 -  Version  2.13:  Add probing for Vendex Headstart Turbo-888-XT system
  4335.           and  any other I/O clock at 300H.  Change I/O clock probing logic to
  4336.           make it less likely to find the wrong type by accident.
  4337.  
  4338. 911129 -  Version  2.12:    Fix handling of Quadram clocks (type 9).  They can
  4339.           only set seconds to zero so generate an error if anyone tries to set
  4340.           the seconds to any other value.
  4341.  
  4342. 911128 -  Version 2.11:  Fix bug in handling clock type 9, Quadram clocks that
  4343.           left  clock  turned  off  after  operations.    Also fix bug in busy
  4344.           determination  for  clock  types  4  and  6  that  could result in a
  4345.           decision that the clock was not operational.
  4346.  
  4347. 911121 -  Version  2.10:    Add  clock  types  6  ,7  and 9.  Add type 8 to do
  4348.           specific probing for the various I/O bus clock types.
  4349.  
  4350. 911109 -  Version 2.05:  Fix bug in leap day handling for I/O clocks.  Fix bug
  4351.           that  caused  hung  systems  when  setting the date or time on Z-18x
  4352.           portables.
  4353.  
  4354.                                       67
  4355.  
  4356.  
  4357.  
  4358.  
  4359.           CLOCK Version 3.70                              November 20, 1994
  4360.  
  4361.  
  4362. 911026 -  Version  2.04:    Add  support  for I/O clocks at addresses 240H and
  4363.           340H.   Reduce resident memory required by clock driver to only that
  4364.           required for specific clock type.
  4365.  
  4366. 911021 -  Version 2.03:  Change handling of new day flag from BIOS to accommo-
  4367.           date BIOSs that indicate multiple days have passed.
  4368.  
  4369. 911020 -  Version  2.02:    Fix bug in returning date on clock read functions.
  4370.           Added message in automatic determination to indicate type found.
  4371.  
  4372. 911010  - Version  2.01:   Added automatic determination of Mitsubishi 8088 PC
  4373.           clocks.    Fixed  handler  to keep the BIOS counter set properly for
  4374.           programs  that  read  it directly.  Also returns a finer granularity
  4375.           value (100ths of seconds) on reads.
  4376.  
  4377. 911009  - Version  2.00:    Modified  clock driver to support additional clock
  4378.           types.    Thanks to Eric Smith (no relation) for help in finding out
  4379.           how the Zenith PC clock worked.
  4380.  
  4381. 911005  - Version  1.20:  Changed prologue and epilogue to conform to DOS 5.00
  4382.           documentation.    Seems to work OK with DOS 5.0 without the changes,
  4383.           but we might as well be consistent to save problems later.
  4384.  
  4385. 910903  - Version  1.10:  Added display of current date and time when initial-
  4386.           izing.
  4387.  
  4388. 910518  - CLOCK  version  1.00.  Initial version developed at the request of a
  4389.           friend with a Sperry PC/HT who wanted to move to DOS 4.01.
  4390.  
  4391. 1984    - Write  clock  device driver for AST clock for IBM PC-1.  This serves
  4392.           as the introduction to what device drivers and especially the CLOCK$
  4393.           driver are all about.
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.                                       68
  4419.